简体   繁体   English

CSS3圆形动画

[英]CSS3 circular animation

I did a CSS3 circular animated menu with the menu items starting from the left end and rotates to the right to their corresponding locations. 我做了一个CSS3圆形动画菜单,菜单项从左端开始,然后向右旋转到相应的位置。
I have put each of the menu items inside a container and made each container to rotate to different angles to bring out the animation. 我已经将每个菜单项放在一个容器中,并使每个容器旋转到不同的角度以显示动画。
What my problem is since each menu item is inside a container, there would be as many as containers as there are menu items which makes it impossible to get the :hover action for the anchor tag inside each menu item since the container is in the top. 我的问题是,由于每个菜单项都在容器内,因此与容器中的菜单项数量一样多,这使得由于每个容器都位于顶部,因此无法对每个菜单项内的anchor标签进行:hover操作。 Can someone suggest a fix for this? 有人可以为此提出建议吗?

You can see it here: 在这里你可以看到它:

http://jsfiddle.net/blueeyes/bWWHm/4/ http://jsfiddle.net/blueeyes/bWWHm/4/

You can see that I am able hover the links aa and fff because aa doesn't have a container and the container of fff is on top of all. 您会看到我能够将链接aafff悬停,因为aa没有容器,而fff的容器是最重要的。
The other links are under the container so not accessible. 其他链接位于容器下方,因此无法访问。

You're overcomplicating things, you don't need a container. 您使事情变得过于复杂,不需要容器。 You just position all menu items absolutely at the center of the circle, then you rotate each one by the desired angle, translate it outwards by the radius of the circle and then rotate it again by the opposite angle to make the text horizontal again. 您只需将所有菜单项绝对定位在圆的中心,然后将每个菜单项旋转所需的角度,将其向外平移圆的半径,然后再次以相反的角度旋转即可使文本再次变为水平。 In this way, the center of each menu item is going to be on the circle. 这样,每个菜单项的中心都将在圆圈上。

DEMO DEMO

HTML : HTML

<ul class='circ-menu'>
  <li><a href='#'>aa</a></li>
  <li><a href='#'>bb</a></li>
  <!-- and so on -->
</ul>

CSS : CSS

.circ-menu {
  position: relative;
  padding: 0;
  width: 10em; height: 10em;
  list-style: none;
}
.circ-menu li {
  position: absolute;
  top: 50%; left: 50%;
  margin: -1.5em;
  width: 3em; height: 3em;
  background: rgba(255, 0, 0, .3);
}
.circ-menu li:first-child {
  transform: rotate(-112.5deg) translateY(-5em) rotate(112.5deg);
}
.circ-menu li:nth-child(2) {
  transform: rotate(-67.5deg) translateY(-5em) rotate(67.5deg);
}
/* and so on */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM