Home  >  Article  >  Web Front-end  >  CSS3动画之:水波涟漪般的定位样式_html/css_WEB-ITnose

CSS3动画之:水波涟漪般的定位样式_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 08:55:391688browse

三月 3, 2016 发表于:HTML & CSS . 评论

赞助商链接

近期工作要做一个用于图像定位的标识,为了让这个指示标识不死板,决定做个简单的动画,动画效果像波浪一样波动,这样标识就更美观好看了,喜欢的同学可以跟着来学,十分简单,欢迎指正交流。

先上效果图:

教程

本动画需要用到的主要属性:animation, transition 和 Keyframes 属性,属性详情可以去 w3school 中文站查看相关动画属性。

Step 1:HTML 代码:

<div class="example"><div class="dot"></div></div>

Step 2: CSS样式:设置animation属性

.dot:before{content:' ';position: absolute;z-index:2;left:0;top:0;width:10px;height:10px;background-color: #ff4200;border-radius: 50%;}.dot:after {content:' ';position: absolute;z-index:1;width:10px;height:10px;background-color: #ff4200;border-radius: 50%;box-shadow: 0 0 10px rgba(0,0,0,.3) inset;-webkit-animation-name:'ripple';/*动画属性名,也就是我们前面keyframes定义的动画名*/-webkit-animation-duration: 1s;/*动画持续时间*/-webkit-animation-timing-function: ease; /*动画频率,和transition-timing-function是一样的*/-webkit-animation-delay: 0s;/*动画延迟时间*/-webkit-animation-iteration-count: infinite;/*定义循环资料,infinite为无限次*/-webkit-animation-direction: normal;/*定义动画方式*/}

设置动画方式,像波浪一样,从小变大变无,所以我们要设置宽高从0 – 50px,透明度从有至无,这样就能实现水波涟漪效果啦。

@keyframes ripple {0% {left:5px;top:5px;opcity:75;width:0;height:0;}100% {left:-20px;top:-20px;opacity: 0;width:50px;height:50px;}}

效果完成了,此案例比较适合图像定位标识用,当然还可以有更好的方案去代替,完善这个样式与动画效果。

在线演示地址: http://codepen.io/commyleung/pen/qZdWrR

交流:想结交更多有才华的设计师?请到(UI设计QQ群)列表,与50000名设计师交流设计。

设计导航:小盆友和大神都值得拥有的设计师网址导航: http://hao.shejidaren.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn