这篇文章给大家分享的是有关CSS3如何实现莲花绽放的动画效果的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
先来看效果:
这效果看起来挺炫,但原理并不复杂,能实现一片花瓣动起来,就能实现9片花瓣。效果的叠加而已。
HTML:
<section class="demo"> <div class="box"> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> </div> </section>
CSS:
View Code body { background-color: #000; } .demo { margin:0px auto; width: 500px; } /*莲花花瓣的容器*/ .box { position: relative;/*设置相对定位,因为花瓣都要进行绝对定位*/ height: 400px; margin-top:400px } /*花瓣进行绝对定位*/ .box .leaf { position: absolute; } /*绘制莲花花瓣*/ .leaf { margin-top:0px; width: 200px; height: 200px; border-radius: 200px 0px;/*制作花瓣角*/ background: -moz-linear-gradient(45deg,rgba(188,190,192,1) 8%,rgba(158,31,99,1) 30%,rgba(158,31,99,1) 100%);/*制作花瓣颜色*/ background: -webkit-linear-gradient(45deg,rgba(188,190,192,1) 8%,rgba(158,31,99,1) 30%,rgba(158,31,99,1) 100%);/*制作花瓣颜色*/ opacity: .6; filter:alpha(opacity=50); transform: rotate(135deg);/*花瓣旋转135deg*/ transform-origin: top right;/*重置花瓣旋转原点,这个很重要*/ } @keyframes show-2 { 0% { transform: rotate(135deg); } 50% { transform: rotate(45deg); } 100%{ transform: rotate(135deg); } } @keyframes show-3 { 0% { transform: rotate(135deg); } 50% { transform: rotate(65deg); } 100%{ transform: rotate(135deg); } } @keyframes show-4 { 0% { transform: rotate(135deg); } 50% { transform: rotate(85deg); } 100%{ transform: rotate(135deg); } } @keyframes show-5 { 0% { transform: rotate(135deg); } 50% { transform: rotate(105deg); } 100%{ transform: rotate(135deg); } } @keyframes show-6 { 0% { transform: rotate(135deg); } 50% { transform: rotate(165deg); } 100%{ transform: rotate(135deg); } } @keyframes show-7 { 0% { transform: rotate(135deg); } 50% { transform: rotate(185deg); } 100%{ transform: rotate(135deg); } } @keyframes show-8 { 0% { transform: rotate(135deg); } 50% { transform: rotate(205deg); } 100%{ transform: rotate(135deg); } } @keyframes show-9 { 0% { transform: rotate(135deg); } 50% { transform: rotate(225deg); } 100%{ transform: rotate(135deg); } } .leaf:nth-child(1) { background: -moz-linear-gradient(45deg,rgba(250,250,250,1) 8%,rgba(158,31,99,1) 30%,rgba(158,31,99,1) 100%);/*制作花瓣颜色*/ } .leaf:nth-child(2) { animation: show-2 6s ease-in-out infinite; } .leaf:nth-child(3) { animation: show-3 6s ease-in-out infinite; } .leaf:nth-child(4) { animation: show-4 6s ease-in-out infinite; } .leaf:nth-child(5) { animation: show-5 6s ease-in-out infinite; } .leaf:nth-child(6) { animation: show-6 6s ease-in-out infinite; } .leaf:nth-child(7) { animation: show-7 6s ease-in-out infinite; } .leaf:nth-child(8) { animation: show-8 6s ease-in-out infinite; } .leaf:nth-child(9) { animation: show-9 6s ease-in-out infinite; }
感谢各位的阅读!关于“CSS3如何实现莲花绽放的动画效果”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。