魔幻般冒泡背景的CSS3按钮动画

所属分类: 网页制作 / CSS 阅读数: 813
收藏 0 赞 0 分享

这是一款非常有特点的CSS3按钮,按钮的背景不是北京图片,也不是单纯的颜色,而是一组魔幻般的冒泡背景动画。当我们将鼠标滑过按钮时,按钮的冒泡背景动画就可以展示出来。可以说这款CSS3按钮的设计风格相当有创意,而且令人惊叹的是,这些动画都是用CSS3实现的,并没有使用JavaScript,非常强大。

HTML代码:

XML/HTML Code复制内容到剪贴板
  1. <div id="buttonContainer">  
  2.   
  3.     <a href="#" class="button big blue">Big Button</a>  
  4.     <a href="#" class="button big green">Big Button</a>  
  5.     <a href="#" class="button big orange">Big Button</a>  
  6.     <a href="#" class="button big gray">Big Button</a>  
  7.   
  8.     <a href="#" class="button blue medium">Medium Button</a>  
  9.     <a href="#" class="button green medium">Medium Button</a>  
  10.     <a href="#" class="button orange medium">Medium Button</a>  
  11.     <a href="#" class="button gray medium">Medium Button</a>  
  12.   
  13.     <a href="#" class="button small blue">Small Button</a>  
  14.     <a href="#" class="button small green">Small Button</a>  
  15.     <a href="#" class="button small blue rounded">Rounded</a>  
  16.   
  17.     <a href="#" class="button small orange">Small Button</a>  
  18.     <a href="#" class="button small gray">Small Button</a>  
  19.   
  20.     <a href="#" class="button small green rounded">Rounded</a>  
  21.   
  22. </div>  

CSS代码:

CSS Code复制内容到剪贴板
  1. .button{   
  2.  font:15px Calibri, Arialsans-serif;   
  3.   
  4.  /* A semi-transparent text shadow */  
  5.  text-shadow:1px 1px 0 rgba(255,255,255,0.4);   
  6.   
  7.  /* Overriding the default underline styling of the links */  
  8.  text-decoration:none !important;   
  9.  whitewhite-space:nowrap;   
  10.   
  11.  display:inline-block;   
  12.  vertical-align:baselinebaseline;   
  13.  position:relative;   
  14.  cursor:pointer;   
  15.  padding:10px 20px;   
  16.   
  17.  background-repeat:no-repeat;   
  18.   
  19.  /* The following two rules are fallbacks, in case  
  20.     the browser does not support multiple backgrounds. */  
  21.   
  22.  background-position:bottombottom left;   
  23.  background-image:url('button_bg.png');   
  24.   
  25.  /* Multiple backgrounds version. The background images  
  26.     are defined individually in color classes */  
  27.   
  28.  background-position:bottombottom lefttop rightright, 0 0, 0 0;   
  29.  background-clip:border-box;   
  30.   
  31.  /* Applying a default border raidus of 8px */  
  32.   
  33.  -moz-border-radius:8px;   
  34.  -webkit-border-radius:8px;   
  35.  border-radius:8px;   
  36.   
  37.  /* A 1px highlight inside of the button */  
  38.   
  39.  -moz-box-shadow:0 0 1px #fff inset;   
  40.  -webkit-box-shadow:0 0 1px #fff inset;   
  41.  box-shadow:0 0 1px #fff inset;   
  42.   
  43.  /* Animating the background positions with CSS3 */  
  44.  /* Currently works only in Safari/Chrome */  
  45.   
  46.  -webkit-transition:background-position 1s;   
  47.  -moz-transition:background-position 1s;   
  48.  transition:background-position 1s;   
  49. }   
  50.   
  51. .button:hover{   
  52.   
  53.  /* The first rule is a fallback, in case the browser  
  54.     does not support multiple backgrounds  
  55.  */  
  56.   
  57.  background-position:top left;   
  58.  background-position:top leftbottombottom rightright, 0 0, 0 0;   
  59. }   
  60.   
  61. .button:active{   
  62.  /* Moving the button 1px to the bottom when clicked */  
  63.  bottombottom:-1px;   
  64. }   
  65.   
  66. /* The three buttons sizes */  
  67.   
  68. .button.big  { font-size:30px;}   
  69. .button.medium { font-size:18px;}   
  70. .button.small { font-size:13px;}   
  71.   
  72. /* A more rounded button */  
  73.   
  74. .button.rounded{   
  75.  -moz-border-radius:4em;   
  76.  -webkit-border-radius:4em;   
  77.  border-radius:4em;   
  78. }   
  79.   
  80. /* Defining four button colors */  
  81.   
  82. /* BlueButton */  
  83.   
  84. .blue.button{   
  85.  color:#0f4b6d !important;   
  86.   
  87.  border:1px solid #84acc3 !important;   
  88.   
  89.  /* A fallback background color */  
  90.  background-color#48b5f2;   
  91.   
  92.  /* Specifying a version with gradients according to */  
  93.   
  94.  background-imageurl('button_bg.png'), url('button_bg.png'),   
  95.       -moz-radial-gradient( center bottombottomcircle,   
  96.             rgba(89,208,244,1) 0,rgba(89,208,244,0) 100px),   
  97.       -moz-linear-gradient(#4fbbf7#3faeeb);   
  98.   
  99.  background-imageurl('button_bg.png'), url('button_bg.png'),   
  100.       -webkit-gradient( radial, 50% 100%, 0, 50% 100%, 100,   
  101.            from(rgba(89,208,244,1)), to(rgba(89,208,244,0))),   
  102.       -webkit-gradient(linear, 0% 0%, 0% 100%, from(#4fbbf7), to(#3faeeb));   
  103. }   
  104.   
  105. .blue.button:hover{   
  106.  background-color:#63c7fe;   
  107.   
  108.  background-imageurl('button_bg.png'), url('button_bg.png'),   
  109.       -moz-radial-gradient( center bottombottomcircle,   
  110.             rgba(109,217,250,1) 0,rgba(109,217,250,0) 100px),   
  111.       -moz-linear-gradient(#63c7fe#58bef7);   
  112.   
  113.  background-imageurl('button_bg.png'), url('button_bg.png'),   
  114.       -webkit-gradient( radial, 50% 100%, 0, 50% 100%, 100,   
  115.            from(rgba(109,217,250,1)), to(rgba(109,217,250,0))),   
  116.       -webkit-gradient(linear, 0% 0%, 0% 100%, from(#63c7fe), to(#58bef7));   
  117. }   
  118.   
  119. /* Green Button */  
  120.   
  121. .green.button{   
  122.  color:#345903 !important;   
  123.  border:1px solid #96a37b !important;    
  124.  background-color#79be1e;   
  125.   
  126.  background-image:url('button_bg.png'), url('button_bg.png'), -moz-radial-gradient(center bottombottomcircle, rgba(162,211,30,1) 0,rgba(162,211,30,0) 100px),-moz-linear-gradient(#82cc27#74b317);   
  127.  background-image:url('button_bg.png'), url('button_bg.png'), -webkit-gradient(radial, 50% 100%, 0, 50% 100%, 100, from(rgba(162,211,30,1)), to(rgba(162,211,30,0))),-webkit-gradient(linear, 0% 0%, 0% 100%, from(#82cc27), to(#74b317));   
  128. }   
  129.   
  130. .green.button:hover{   
  131.  background-color:#89d228;   
  132.   
  133.  background-image:url('button_bg.png'), url('button_bg.png'), -moz-radial-gradient(center bottombottomcircle, rgba(183,229,45,1) 0,rgba(183,229,45,0) 100px),-moz-linear-gradient(#90de31#7fc01e);   
  134.  background-image:url('button_bg.png'), url('button_bg.png'), -webkit-gradient(radial, 50% 100%, 0, 50% 100%, 100, from(rgba(183,229,45,1)), to(rgba(183,229,45,0))),-webkit-gradient(linear, 0% 0%, 0% 100%, from(#90de31), to(#7fc01e));   
  135. }   
  136.   
  137. /* Orange Button */  
  138.   
  139. .orange.button{   
  140.  color:#693e0a !important;   
  141.  border:1px solid #bea280 !important;    
  142.  background-color#e38d27;   
  143.   
  144.  background-image:url('button_bg.png'), url('button_bg.png'), -moz-radial-gradient(center bottombottomcircle, rgba(232,189,45,1) 0,rgba(232,189,45,0) 100px),-moz-linear-gradient(#f1982f#d4821f);   
  145.  background-image:url('button_bg.png'), url('button_bg.png'), -webkit-gradient(radial, 50% 100%, 0, 50% 100%, 100, from(rgba(232,189,45,1)), to(rgba(232,189,45,0))),-webkit-gradient(linear, 0% 0%, 0% 100%, from(#f1982f), to(#d4821f));   
  146. }   
  147.   
  148. .orange.button:hover{   
  149.  background-color:#ec9732;   
  150.   
  151.  background-image:url('button_bg.png'), url('button_bg.png'), -moz-radial-gradient(center bottombottomcircle, rgba(241,192,52,1) 0,rgba(241,192,52,0) 100px),-moz-linear-gradient(#f9a746#e18f2b);   
  152.  background-image:url('button_bg.png'), url('button_bg.png'), -webkit-gradient(radial, 50% 100%, 0, 50% 100%, 100, from(rgba(241,192,52,1)), to(rgba(241,192,52,0))),-webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9a746), to(#e18f2b));   
  153. }   
  154.   
  155. .gray.button{   
  156.  color:#525252 !important;   
  157.  border:1px solid #a5a5a5 !important;    
  158.  background-color#a9adb1;   
  159.   
  160.  background-image:url('button_bg.png'), url('button_bg.png'), -moz-radial-gradient(center bottombottomcircle, rgba(197,199,202,1) 0,rgba(197,199,202,0) 100px),-moz-linear-gradient(#c5c7ca#92989c);   
  161.  background-image:url('button_bg.png'), url('button_bg.png'), -webkit-gradient(radial, 50% 100%, 0, 50% 100%, 100, from(rgba(197,199,202,1)), to(rgba(197,199,202,0))),-webkit-gradient(linear, 0% 0%, 0% 100%, from(#c5c7ca), to(#92989c));   
  162. }   
  163.   
  164. .gray.button:hover{   
  165.  background-color:#b6bbc0;   
  166.   
  167.  background-image:url('button_bg.png'), url('button_bg.png'), -moz-radial-gradient(center bottombottomcircle, rgba(202,205,208,1) 0,rgba(202,205,208,0) 100px),-moz-linear-gradient(#d1d3d6#9fa5a9);   
  168.  background-image:url('button_bg.png'), url('button_bg.png'), -webkit-gradient(radial, 50% 100%, 0, 50% 100%, 100, from(rgba(202,205,208,1)), to(rgba(202,205,208,0))),-webkit-gradient(linear, 0% 0%, 0% 100%, from(#d1d3d6), to(#9fa5a9));   
  169. }   

以上就是本文的全部内容,希望对大家的学习有所帮助。

更多精彩内容其他人还在看

CSS入门教程:计算CSS盒模型宽和高

 出处:当我们布局一个网页的时候,经常会遇到这样的一种情况,那就是最终网页成型的宽度或是高度会超出我们预先的计算,其实就就是所谓的CSS的盒模型造成的。 #test{margin:10px;padding:10px;width:100px;height:100px;}
收藏 0 赞 0 分享

在IE流览器中正确显示PNG透明图片

  png图片有很好的品质。阴影效果也不会有杂边,很流畅。如果插入网页的话可以给网站内容增色不少!更重要的是在不增加图片容量大小的情况下提高了页面的图片的质量。对于有复杂背景,如:在有颜色过度背景上插入不规则边框的图片带来极大很便利!   但目前IE中对于插入
收藏 0 赞 0 分享

CSS教程:DIV底部放置文字

  css对文字的布局上没有靠容器底部对齐的参数,目前使用的一个不错的方法也比较好.就是用position属性来解决,看下面的代码,用position的相对和绝对定位功能也轻松的实现了,文字靠近div低部对齐,并且靠近的距离还可以精确到像素,自己可以调节,是不是很不错呢?
收藏 0 赞 0 分享

如何用CSS让文字居于div的底部

  这个问题是别人提出的,因为css对文字的布局上没有靠容器底部对齐的参数,(或许有但是我没有发现)不过目前我使用的一个不错的方法也比较好.就是用position属性来解决,看下面的代码,我用position的相对和绝对定位功能也轻松的实现了,文字靠近div低部对齐,并且靠近
收藏 0 赞 0 分享

从A页面连接到B页面后并直接把B页面的隐藏层显示

  这个效果实现的是,在B页面里有两个层,一个显示层,我们暂定名c层,一个是隐藏层,我们暂定名d层,单独进B页面的时候,c层显示,d层隐藏,然而从A页面连接到B页面的时候,则是让d层显示,c层隐藏,我觉得这个效果对网页设计者以后会有很大帮助,现在把代码发出来,
收藏 0 赞 0 分享

CSS样式表定义标签li前面样式

定义LI前面的小点样式 view plaincopy to clipboardprint? 语法: list-style-type : disc | circle | square | decimal | lower-roman | upper-roman | lowe
收藏 0 赞 0 分享

符合标准的div css制作的弹出菜单

本文介绍了五款符合标准的div css制作的弹出菜单,而且不含有js的. NO.1最基本的:二级dropdown弹出菜单 <!DOCTYPE html PUB
收藏 0 赞 0 分享

CSS实现在文章每段后面加入带连接的隐藏文字

代码主要理解3个参数:createElement、createTextNode、appendChild。这3个js参数分别是创建元素、创建字符、追加节点。代码原理:循环页面段落标签<p>,创建连接元素<a>,创建要显示的连接字符,用SetAttribute
收藏 0 赞 0 分享

CSS:浏览器特定选择器介绍

当你想在一个浏览器里改变样式而不像在其他浏览器中改变时,这些选择器很有用。 IE6以下 *html{} IE 7 以下 *:first-child html {} * html {} 只对IE 7 *:first-child html {} 只对IE 7
收藏 0 赞 0 分享

WEB标准学习,认识两种网页声明的含义

即网页标准推出来以后,我们时常会看到两种不同的网页的声明,一个是Dhtml,一个是Xhtml。如下所示: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "ht
收藏 0 赞 0 分享
查看更多