css3 扇形动画

扇形动画,因为我工作中遇到了只执行一次就ok,所以没细研究,该css暂时只能执行1次扇形动画,无限循环会有问题。

css:

@keyframes rotateAn{
    0%{transform: rotate(0deg); }
    99%{ transform: rotate(180deg); opacity: 0.8; }
    100%{ transform: rotate(180deg); opacity: 0; }
}
*{margin: 0; padding: 0;}
.circle-dev{ width: 200px; height: 200px; border-radius: 100px; overflow: hidden; position: relative; }
.circle-bg, .circle-alt{ width: 100%; height: 100%; border-radius: 50%; background: #ccc; position: absolute; top: 0; left: 0; }
.circle-alt{ opacity: 0.4; }
.circle-alt-lft, .circle-alt-rht{ position: absolute; width: 50%; height: 100%; top:0; }
.circle-alt-lft{left: 0; overflow: hidden; border-radius: 50% 0 0 50%; }
.circle-alt-lft:after{ background: #fff; opacity: 0.8; display: block; content: ""; width: 100%; height: 100%; transform-origin: right center; animation: rotateAn 1s 1s linear forwards;}
.circle-alt-rht{ right: 0; overflow: hidden; border-radius: 0 50% 50% 0; }
.circle-alt-rht:after{ background: #fff; opacity: 0.8; display: block; content: ""; width: 100%; height: 100%; transform-origin: left center; animation: rotateAn 1s linear forwards;}

html:

<div class="circle-dev">
    <div class="circle-bg"></div>
    <div class="circle-alt">
        <div class="circle-alt-lft"></div>
        <div class="circle-alt-rht"></div>
    </div>
</div>

 ps:我这里为了省事简化了,css3上少了webkit前缀,在移动端上使用时,一定要在css3的上面加上-webkit-。这里需要加上-webkit-的是:

transform-origin、
animation、
keyframes、
transform

重要的事情说三遍:

加上-webkit-!加上-webkit-!加上-webkit-!否则移动端上将会出错。

 

posted on 2016-05-11 22:38  安蝶 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/cyj7/p/5483882.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明
可以使用 CSS3 中的 transform 属性和 transition 属性来实现点击扇形展开效果。 首先,需要将扇形的 HTML 结构设置为一个 div 容器和多个子元素,每个子元素代表一个扇形。容器需要设置为圆形,并将所有子元素都设置为绝对定位,位置重合在圆心上。 然后,通过设置每个扇形transform 属性,将其旋转到对应的位置。需要注意的是,每个扇形应该以圆心为中心旋转,角度根据扇形数量平均分配。 最后,通过设置容器的 transform 属性,在点击扇形时将其展开。可以使用 transition 属性来实现平滑的动画效果。 以下是一个示例代码: ``` .container { position: relative; width: 200px; height: 200px; border-radius: 50%; background-color: gray; } .item { position: absolute; top: 50%; left: 50%; width: 50px; height: 50px; margin-top: -25px; margin-left: -25px; transform-origin: 0% 0%; transition: transform 0.2s; } .item:nth-child(1) { transform: rotate(0deg) translate(100px) rotate(-90deg); } .item:nth-child(2) { transform: rotate(45deg) translate(100px) rotate(-45deg); } .item:nth-child(3) { transform: rotate(90deg) translate(100px) rotate(0deg); } .item:nth-child(4) { transform: rotate(135deg) translate(100px) rotate(45deg); } .item:nth-child(5) { transform: rotate(180deg) translate(100px) rotate(90deg); } .item:nth-child(6) { transform: rotate(225deg) translate(100px) rotate(135deg); } .item:nth-child(7) { transform: rotate(270deg) translate(100px) rotate(180deg); } .item:nth-child(8) { transform: rotate(315deg) translate(100px) rotate(225deg); } .item:hover { transform: scale(1.2); } .container:hover .item { transform: translate(-50%, -50%) scale(1.2); } ``` 在 HTML 中,扇形的容器和子元素可以这样定义: ``` <div class="container"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div> ``` 在 CSS 中,需要定义每个子元素的 transform 属性,以及容器的 transform 属性和 transition 属性。当鼠标悬停在子元素上时,可以通过设置其 transform 属性来实现放大效果;当鼠标悬停在容器上时,可以通过设置所有子元素的 transform 属性来实现展开效果。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值