(转)不用图片 只用css制作…

首先来看看效果图:

HTML 代码就这么简单:

 button

 button

 button

如果没有 CSS ,那么上面的 HTML 执行起来是这样的:

开始 CSS3 的编写:

.button {

     display: inline-block;

     position: relative;

     margin: 10px;

     padding: 0 20px;

     text-align: center;

     text-decoration: none;

     font: bold 12px/25px Arial, sans-serif;

 }

一些不同颜色的按钮样式:

 

 .green {

     color: #3e5706;

     background: #a5cd4e;

 }

  

 

  

 .blue {

     color: #19667d;

     background: #70c9e3;

 }

  

 

  

 .gray {

     color: #515151;

     background: #d3d3d3;

 }
 

到这一步后按钮看起来是这样的:

 

接下来开始用 CSS 处理圆角:

 .button {

     display: inline-block;

     position: relative;

     margin: 10px;

     padding: 0 20px;

     text-align: center;

     text-decoration: none;

     font: bold 12px/25px Arial, sans-serif;

  

     text-shadow: 1px 1px 1px rgba(255,255,255, .22);

  

     -webkit-border-radius: 30px;

     -moz-border-radius: 30px;

     border-radius: 30px;

  

     -webkit-box-shadow: 1px 1px 1px rgba(0,0,0, .29), inset 1px 1px 1pxrgba(255,255,255, .44);

     -moz-box-shadow: 1px 1px 1px rgba(0,0,0, .29), inset 1px 1px 1px rgba(255,255,255, .44);

     box-shadow: 1px 1px 1px rgba(0,0,0, .29), inset 1px 1px 1px rgba(255,255,255, .44);

  

     -webkit-transition: all 0.15s ease;

     -moz-transition: all 0.15s ease;

     -o-transition: all 0.15s ease;

     -ms-transition: all 0.15s ease;

     transition: all 0.15s ease;

 }

 

现在的按钮圆润多了,看看:

 

还不够啊,没有立体效果,再完善完善:

 

  

 .green {

     color: #3e5706;

  

     background: #a5cd4e;

     background: -moz-linear-gradient(top,  #a5cd4e 0%, #6b8f1a 100%);

     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a5cd4e), color-stop(100%,#6b8f1a));

     background: -webkit-linear-gradient(top,  #a5cd4e 0%,#6b8f1a 100%);

     background: -o-linear-gradient(top,  #a5cd4e 0%,#6b8f1a 100%);

     background: -ms-linear-gradient(top,  #a5cd4e 0%,#6b8f1a 100%);

     background: linear-gradient(top,  #a5cd4e 0%,#6b8f1a 100%);

 }

  

 

  

 .blue {

     color: #19667d;

  

     background: #70c9e3;

     background: -moz-linear-gradient(top,  #70c9e3 0%, #39a0be 100%);

     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#70c9e3), color-stop(100%,#39a0be));

     background: -webkit-linear-gradient(top,  #70c9e3 0%,#39a0be 100%);

     background: -o-linear-gradient(top,  #70c9e3 0%,#39a0be 100%);

     background: -ms-linear-gradient(top,  #70c9e3 0%,#39a0be 100%);

     background: linear-gradient(top,  #70c9e3 0%,#39a0be 100%);

 }

  

 

  

 .gray {

     color: #515151;

  

     background: #d3d3d3;

     background: -moz-linear-gradient(top,  #d3d3d3 0%, #8a8a8a 100%);

     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d3d3d3), color-stop(100%,#8a8a8a));

     background: -webkit-linear-gradient(top,  #d3d3d3 0%,#8a8a8a 100%);

     background: -o-linear-gradient(top,  #d3d3d3 0%,#8a8a8a 100%);

     background: -ms-linear-gradient(top,  #d3d3d3 0%,#8a8a8a 100%);

     background: linear-gradient(top,  #d3d3d3 0%,#8a8a8a 100%);

 }

 

现在爽了,漂亮了,你喜欢这样的按钮吗?

 

为了让按钮更大一点,我们增加了个 big 样式:

 

 sign in One minute

 sign in One minute

 sign in One minute
 

 

  

 .big {

     padding: 0 40px;

     padding-top: 10px;

     height: 45px;

     text-transform: uppercase;

     font: bold 20px/22px Arial, sans-serif;

 }

  

 .big span {

     display: block;

     text-transform: none;

     font: italic normal 12px/18px Georgia, sans-serif;

     text-shadow: 1px 1px 1px rgba(255,255,255, .12);

 }
 

大按钮的效果:

 

我们还需要处理下当鼠标移到按钮上方时显示不同的效果:

 view source print?01 .button:hover {

     -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,.29), inset 0px 0px 2px rgba(0,0,0, .5);

     -moz-box-shadow: 1px 1px 1px rgba(0,0,0,.29), inset 0px 0px 2px rgba(0,0,0, .5);

     box-shadow: 1px 1px 1px rgba(0,0,0,.29), inset 0px 0px 2px rgba(0,0,0, .5);

 }

 .button:active {

     -webkit-box-shadow: inset 0px 0px 3px rgba(0,0,0, .8);

     -moz-box-shadow: inset 0px 0px 3px rgba(0,0,0, .8);

     box-shadow: inset 0px 0px 3px rgba(0,0,0, .8);

 }

 

 

效果如下:

好了,完美的CSS3按钮解决方案。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值