这款CSS3动画按钮非常的有创意,鼠标在滑过按钮时并不像其他按钮那样仅仅改变按钮的背景颜色,而是出现很酷的冒泡动画。这么惊艳的CSS3动画按钮,这篇文章主要将按钮实现的过程和代码分享给大家,希望能给在学习CSS3的同学带来实质性的帮助。可以下来看看在线演示效果:

在线演示        源码下载

接下来我们来讲解一下这款CSS3气泡动画的按钮实现过程,主要由HTML代码和CSS代码组成。

HTML代码:

<div id="buttonContainer">

    <a href="#">Big Button</a>
<a href="#">Big Button</a>
<a href="#">Big Button</a>
<a href="#">Big Button</a> <a href="#">Medium Button</a>
<a href="#">Medium Button</a>
<a href="#">Medium Button</a>
<a href="#">Medium Button</a> <a href="#">Small Button</a>
<a href="#">Small Button</a>
<a href="#">Rounded</a> <a href="#">Small Button</a>
<a href="#">Small Button</a> <a href="#">Rounded</a> </div>

HTML代码相对比较简单,即用一个个a链接构造按钮,当然演示中的效果还需要CSS的大力渲染才行。

接下来的重点是CSS代码,首先我们来为每一个button渲染基础的样式,这些样式都是每一个按钮所共有的:

.button{
font:15px Calibri, Arial, sans-serif; /* A semi-transparent text shadow */
text-shadow:1px 1px 0 rgba(255,255,255,0.4); /* Overriding the default underline styling of the links */
text-decoration:none !important;
white-space:nowrap; display:inline-block;
vertical-align:baseline;
position:relative;
cursor:pointer;
padding:10px 20px; background-repeat:no-repeat; /* The following two rules are fallbacks, in case
the browser does not support multiple backgrounds. */ background-position:bottom left;
background-image:url('button_bg.png'); /* Multiple backgrounds version. The background images
are defined individually in color classes */ background-position:bottom left, top right, 0 0, 0 0;
background-clip:border-box; /* Applying a default border raidus of 8px */ -moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px; /* A 1px highlight inside of the button */ -moz-box-shadow:0 0 1px #fff inset;
-webkit-box-shadow:0 0 1px #fff inset;
box-shadow:0 0 1px #fff inset; /* Animating the background positions with CSS3 */
/* Currently works only in Safari/Chrome */ -webkit-transition:background-position 1s;
-moz-transition:background-position 1s;
transition:background-position 1s;
} .button:hover{ /* The first rule is a fallback, in case the browser
does not support multiple backgrounds
*/ background-position:top left;
background-position:top left, bottom right, 0 0, 0 0;
} .button:active{
/* Moving the button 1px to the bottom when clicked */
bottom:-1px;
}

同样也定义了按钮在鼠标滑过和被激活时的样式。

最后是气泡动画特效,我们拿其中一个按钮为例,代码如下:

.blue.button{
color:#0f4b6d !important; border:1px solid #84acc3 !important; /* A fallback background color */
background-color: #48b5f2; /* Specifying a version with gradients according to */ background-image: url('button_bg.png'), url('button_bg.png'),
-moz-radial-gradient( center bottom, circle,
rgba(89,208,244,1) 0,rgba(89,208,244,0) 100px),
-moz-linear-gradient(#4fbbf7, #3faeeb); background-image: url('button_bg.png'), url('button_bg.png'),
-webkit-gradient( radial, 50% 100%, 0, 50% 100%, 100,
from(rgba(89,208,244,1)), to(rgba(89,208,244,0))),
-webkit-gradient(linear, 0% 0%, 0% 100%, from(#4fbbf7), to(#3faeeb));
} .blue.button:hover{
background-color:#63c7fe; background-image: url('button_bg.png'), url('button_bg.png'),
-moz-radial-gradient( center bottom, circle,
rgba(109,217,250,1) 0,rgba(109,217,250,0) 100px),
-moz-linear-gradient(#63c7fe, #58bef7); background-image: url('button_bg.png'), url('button_bg.png'),
-webkit-gradient( radial, 50% 100%, 0, 50% 100%, 100,
from(rgba(109,217,250,1)), to(rgba(109,217,250,0))),
-webkit-gradient(linear, 0% 0%, 0% 100%, from(#63c7fe), to(#58bef7));
}

从代码中我们可以看出,当鼠标滑过按钮时,按钮中的气泡背景图片将实现渐变的动画效果,并加以一定的透明效果,这样便出现了气泡上升的动画特效。所有的代码就是这样,你可以下载源代码来研究。

在线演示        源码下载

纯CSS3冒泡动画按钮实现教程的更多相关文章

  1. 冒泡动画按钮的简单实现(使用CSS3)

    冒泡动画按钮的简单实现(使用CSS3) 原始的参考文章是 http://tutorialzine.com/2010/10/css3-animated-bubble-buttons/ ,基本原理是利用了 ...

  2. 一款基于css3的动画按钮

    之前为大家分享了 推荐10款纯css3实现的实用按钮.今天给大家带来一款基于css3的动画按钮.实现的效果图如下: 在线预览   源码下载 实现的代码. html代码: <div class=& ...

  3. 超酷!纯CSS3烧烤动画实现教程

    今天在老外的网站上看到一款很有创意的纯CSS3动画,是模拟烧烤活动的.款动画模拟了一个烧烤架,烧烤架上的食物也都是用纯CSS3绘制而成,没有用一张图片,效果相当逼真.另外一个有意思的是,这个CSS3烧 ...

  4. 纯CSS3带动画效果导航菜单

    随着互联网的发展,网页能表现的东西越来越多.由最开始单纯的文字和链接构成的网页,到后来的表格布局,再到div+css模式,现在发展到了html+css3.网页能表达的东西越来越多,css3兴起已经很多 ...

  5. 纯css3云彩动画效果

      效果描述: 纯CSS3实现的云彩动画飘动效果 非常逼真实用 使用方法: 1.将body中的代码部分拷贝到你的页面中 2.引入对应的CSS文件即可

  6. 纯css3天气动画场景特效

    CSS3超强大,以下是纯用CSS3+HTML实现的场景效果图: 查看效果:http://hovertree.com/h/bjaf/cssrotate.htm css3 3d展示中rotate()介绍与 ...

  7. 纯CSS3垂直动画菜单

    在线演示 本地下载

  8. 8个超炫酷的纯CSS3动画及源码分享

    在现代网页中,我们已经越来越习惯使用大量的CSS3元素,而现在的浏览器也基本都支持CSS3,所以很多时候我们不妨思考一下是否可以用纯CSS3制作一些有趣或者实用的网页.本文要分享8个超炫酷的纯CSS3 ...

  9. 纯CSS3超酷3D旋转立方体动画特效

    简要教程 这是一款神奇的纯 CSS3 立方体动画特效插件.使用CSS3来制作动画效果已经成为WEB前端开发的一种时尚,从简单的颜色和尺寸动画,到复杂的旋转.翻转动画, CSS3 展现了它无穷的魅力.使 ...

随机推荐

  1. BZOJ3861 : Tree

    把集合看成左边的点,图中的点看成右边的点,若集合$i$不包含$j$,则连边$i->j$,得到一个二分图,等价于求这个二分图的完备匹配个数. 设$f[i][j]$表示考虑了前$i$个集合,匹配了$ ...

  2. Saltstack 分发

    把master上的hosts文件分发到所有主机 [root@node1 ~]# salt-cp '*' /etc/hosts /etc

  3. PHPMailer 使用方法(支持群发):

    一.下载函数包 地址:https://github.com/PHPMailer/PHPMailer 二.测试服务器环境 通过phpinfo()函数打印出是否支持Sockets(Socket属于php的 ...

  4. svnkit https 忽略证书认证

    直接上代码 解决jdk版本问题:Security.setProperty("jdk.tls.disabledAlgorithms", ""); import j ...

  5. spring和springMVC的面试问题总结

    1.Spring中AOP的应用场景.Aop原理.好处? 答:AOP--Aspect Oriented Programming面向切面编程:用来封装横切关注点,具体可以在下面的场景中使用: Authen ...

  6. react-native学习资源

    转载链接:  http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/react-native-learning-resources/ 这是 ...

  7. PID控制器(比例-积分-微分控制器)- V

    Linear Actuator - PID Control Introduction This application guide is designed to explain the basics ...

  8. 解决 Mac 的 Terminal 中,Java 乱码的问题

    在 .bash_profile 文件中,增加如下行: export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 然后,重新加载该配置 source .bash_pr ...

  9. iOS开发-UIView扩展CGRect

    关于UIView的位置都会遇到,一般需要改变UIView的位置,需要先获取原有的frame位置,然后在frame上面修改,有的时候如果只是改变了一下垂直方向的位置,宽度和高度的一种,这种写法很麻烦.下 ...

  10. CentOS7下FTP的安装与配置

    1.安装vsftpd 1 [root@localhost modules]# yum install -y vsftpd 2.编辑ftp配置文件 1 [root@localhost modules]# ...