温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CSS3实现动画按钮代码分享

发布时间:2021-08-10 21:11:12 来源:亿速云 阅读:95 作者:chen 栏目:web开发

本篇内容介绍了“CSS3实现动画按钮代码分享”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

  今天来分享很不错的CSS3按钮动画,这款CSS3按钮一共有5种动画方式,每一种都是鼠标滑过动画形式,虽然这些动画按钮不是十分华丽,但是小编觉得不像其他按钮那样很难扩展,我们可以修改CSS代码随意改变自己喜欢的颜色样式。

CSS3实现动画按钮代码分享

  让我们一起来看看实现这5中样式动画按钮的HTML代码和CSS代码吧。以第一个按钮为例,其他按钮的代码大家可以下载源代码来研究,并不是很难。

  HTML代码:

XML/HTML Code复制内容到剪贴板

  1. <div class="button01">  

  2.       <a href="#">Download</a>  

  3.       <p class="top">click to begin</p>  

  4.       <p class="bottom">1.2MB .zip</p>  

  5. </div>  

  CSS代码:

CSS Code复制内容到剪贴板

  1. .button01 {   

  2.   width200px;   

  3.   margin50px auto 20px auto;   

  4. }   

  5.   

  6. .button01 a {   

  7.   displayblock;   

  8.   height50px;   

  9.   width200px;   

  10.   

  11.   /*TYPE*/  

  12.   colorwhite;   

  13.   font17px/50px HelveticaVerdanasans-serif;   

  14.   text-decorationnone;   

  15.   text-aligncenter;   

  16.   text-transformuppercase;   

  17.   

  18.   /*GRADIENT*/     

  19.   background#00b7ea/* Old browsers */  

  20.   background: -moz-linear-gradient(top#00b7ea 0%, #009ec3 100%); /* FF3.6+ */  

  21.   background: -webkit-gradient(linear, left topleft bottombottomcolor-stop(0%,#00b7ea), color-stop(100%,#009ec3)); /* Chrome,Safari4+ */  

  22.   background: -webkit-linear-gradient(top#00b7ea 0%,#009ec3 100%); /* Chrome10+,Safari5.1+ */  

  23.   background: -o-linear-gradient(top#00b7ea 0%,#009ec3 100%); /* Opera 11.10+ */  

  24.   background: -ms-linear-gradient(top#00b7ea 0%,#009ec3 100%); /* IE10+ */  

  25.   background: linear-gradient(top#00b7ea 0%,#009ec3 100%); /* W3C */  

  26.   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */  

  27. }   

  28.   

  29. .button01 a, p {   

  30.     -webkit-border-radius: 10px;   

  31.      -moz-border-radius: 10px;   

  32.           border-radius: 10px;   

  33.   

  34.   -webkit-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);   

  35.      -moz-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);   

  36.           box-shadow: 2px 2px 8px rgba(0,0,0,0.2);   

  37. }   

  38.   

  39. p {   

  40.   background#222;   

  41.   displayblock;   

  42.   height40px;   

  43.   width180px;    

  44.   margin: -50px 0 0 10px;   

  45.   

  46.   /*TYPE*/  

  47.   text-aligncenter;   

  48.   font12px/45px HelveticaVerdanasans-serif;   

  49.   color#fff;   

  50.   

  51.   /*POSITION*/  

  52.   positionabsolute;   

  53.   z-index: -1;   

  54.   

  55.   /*TRANSITION*/     

  56.   -webkit-transition: margin 0.5s ease;   

  57.      -moz-transition: margin 0.5s ease;   

  58.        -o-transition: margin 0.5s ease;   

  59.       -ms-transition: margin 0.5s ease;   

  60.           transition: margin 0.5s ease;   

  61. }   

  62.   

  63. /*HOVER*/  

  64. .button01:hover .bottombottom {   

  65.   margin: -10px 0 0 10px;   

  66. }   

  67.   

  68. .button01:hover .top {   

  69.   margin: -80px 0 0 10px;   

  70.   line-height35px;   

  71. }   

  72.   

  73. /*ACTIVE*/  

  74. .button01 a:active {   

  75.       background#00b7ea/* Old browsers */  

  76.       background: -moz-linear-gradient(top,  #00b7ea 36%, #009ec3 100%); /* FF3.6+ */  

  77.       background: -webkit-gradient(linear, left topleft bottombottomcolor-stop(36%,#00b7ea), color-stop(100%,#009ec3)); /* Chrome,Safari4+ */  

  78.       background: -webkit-linear-gradient(top,  #00b7ea 36%,#009ec3 100%); /* Chrome10+,Safari5.1+ */  

  79.       background: -o-linear-gradient(top,  #00b7ea 36%,#009ec3 100%); /* Opera 11.10+ */  

  80.       background: -ms-linear-gradient(top,  #00b7ea 36%,#009ec3 100%); /* IE10+ */  

  81.       background: linear-gradient(top,  #00b7ea 36%,#009ec3 100%); /* W3C */  

  82.       filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */  

  83.   

  84. }   

  85.   

  86. .button01:active .bottombottom {   

  87.   margin: -20px 0 0 10px;   

  88. }   

  89.   

  90. .button01:active .top {   

  91.   margin: -70px 0 0 10px;   

  92. }  

“CSS3实现动画按钮代码分享”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI