前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >css3按钮

css3按钮

作者头像
码客说
发布2019-10-22 13:53:14
7530
发布2019-10-22 13:53:14
举报
文章被收录于专栏:码客码客码客

步骤

一、做出圆角图形
二、在圆角图像实现渐变
三、给图形加阴影
四、给文字加阴影

css

.button {
    display: inline-block;
    outline: none;
    text-align: center;
    text-decoration: none;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .3); /*文字阴影*/
    -webkit-border-radius: .5em; /*圆角*/
    -moz-border-radius: .5em;
    border-radius: .5em;
    -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .2); /*阴影*/
    -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}

.button:hover {
    text-decoration: none;
}

.button:active {
    position: relative;
    top: 0px;
}

.orange {
    color: #fef4e9;
    border: solid 1px #da7c0c;
    background: #f78d1d;
    background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20)); /*渐变*/
    background: -webkit-linear-gradient(top, #faa51a, #f47a20);
    background: -moz-linear-gradient(top, #faa51a, #f47a20);
    background: -o-linear-gradient(top, #faa51a, #f47a20);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20'); /*IE不支持渐变,可以借助滤镜,但是滤镜无法实现圆角渐变,如果按钮要圆角可以把IE这两句去掉,即IE无渐变*/
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#faa51a, endColorstr=#f47a20)";
}

.orange:hover {
    background: #f47c20;
    background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
    background: -moz-linear-gradient(top, #f88e11, #f06015);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}

.orange:active {
    color: #fcd3a5;
    background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
    background: -moz-linear-gradient(top, #f47a20, #faa51a);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
}

调用方式

<a href="#" class="button orange">Orange</a>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-10-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 步骤
  • css
  • 调用方式
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档