[css3]圆盘旋转动画

效果:打开只能看到logo,鼠标放上去,圆盘渐显放大旋转展示出来

知识点:

[html+css]

1.logo水平垂直居中于圆盘内,用到的样式

 position: absolute; left: 0; top: 0; bottom: 0; right: 0; margin:auto;

2.放大旋转用transform的scale和rotate,渐显用opacity,动画过度自然用transition

3.背景用rgba的好处:opacity会作用于整个元素和他的子元素,rgba的透明度不会影响他的子元素

[js]

1.每个小图标的位置用数学方法里的sin和cos来计算,注:每个小图标的margin-top和margin-left应为自身宽高一半的负值,才能正确定位

 

<nav>
  <a href="" class="logo"></a>
  <div class="ring">
    <a href="" class="icon"></a>
	<a href="" class="icon"></a>
	<a href="" class="icon"></a>
	<a href="" class="icon"></a>
	<a href="" class="icon"></a>
	<a href="" class="icon"></a>
	<a href="" class="icon"></a>
	<a href="" class="icon"></a>
  </div>			
</nav>

 

<style type="text/css">
nav{ position: relative; width: 256px; height: 256px; border-radius: 50%; margin: 100px auto;}
.ring{ position: relative; width: 256px; height: 256px; border-radius: 50%; margin: 0 auto; background: rgba(0,0,0,.4); transform: scale(0.1) 
rotate(-270deg); opacity: 0; transition: all 500ms;} .ring:hover{ transform: scale(1.1) rotate(0); opacity: 1;} .logo{ position: absolute; display: block; width: 80px; height: 80px; margin: auto; border: 2px solid #fff; border-radius: 50%; left: 0; top: 0;
bottom: 0; right: 0; background: rgba(0,0,0,.5) url(img/logo.png) no-repeat center;} .ring a{ position: absolute; display: block; width: 40px; height: 40px; margin-left: -20px; margin-top: -20px; border-radius: 50%;} .ring a:nth-child(1){ background: url(img/1_28.png) no-repeat top #fff;} //:nth-child()是css3选择器,background-color不能直接写到a里,会被:nth-child()覆盖 .ring a:nth-child(2){ background: url(img/1_29.png) no-repeat top #fff;} .ring a:nth-child(3){ background: url(img/1_30.png) no-repeat top #fff;} .ring a:nth-child(4){ background: url(img/1_31.png) no-repeat top #fff;} .ring a:nth-child(5){ background: url(img/1_32.png) no-repeat top #fff;} .ring a:nth-child(6){ background: url(img/1_33.png) no-repeat top #fff;} .ring a:nth-child(7){ background: url(img/1_34.png) no-repeat top #fff;} .ring a:nth-child(8){ background: url(img/1_35.png) no-repeat top #fff;} </style>

 

<script type="text/javascript">
var $icon=$(".icon");
for(var i=0,l=$icon.length;i<l;i++){
  var _left=(50-35*Math.cos(-0.5*Math.PI-2*(1/l)*i*Math.PI)).toFixed(4)+"%";
  var _top=(50+35*Math.sin(-0.5*Math.PI-2*(1/l)*i*Math.PI)).toFixed(4)+"%";
  $icon.eq(i).css({"left":_left,"top":_top});
}
</script>

 

转载于:https://www.cnblogs.com/zhangwenkan/p/4723625.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值