Rumah > php教程 > PHP开发 > 几款纯css打造的超酷按钮实例

几款纯css打造的超酷按钮实例

WBOY
Lepaskan: 2016-06-07 17:23:22
asal
1277 orang telah melayarinya

在web开发中,您是否还在使用Photoshop来设计按钮的样式呢?如果是,请先把Photoshop放下,来看看几款纯css打造的扫钮,或许正是你想要的。


随着CSS3技术的发展,你完全可以不需要借助任何图片和javascript脚本,而只需通过几行代码来定制一个漂亮的按钮,并且还可以呈现渐变、框阴影、文字阴影等效果。此类按钮最大的优势是省去了加载图片的步骤,并且非常易于编辑、扩展和定制,你只需要更改代码即可。


经测试,Chrome、Firefox、360和百度等浏览器(我的电脑就安装了这几款)可以完美支持,至于其它浏览器,欢迎网友提供答案。好了,先看效果图:

几款纯css打造的超酷按钮实例

再来一个大的

几款纯css打造的超酷按钮实例

下面是与之相应的代码:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>几款纯css打造的超酷按钮实例</title>
<style type="text/css">
.button {
    display: inline-block;
    outline: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font: 16px/100% &#39;Microsoft yahei&#39;,Arial, Helvetica, sans-serif;
    padding: .5em 2em .55em;
    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: 1px;
}
.bigrounded {
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em;
}
.medium {
    font-size: 12px;
    padding: .4em 1.5em .42em;
}
.small {
    font-size: 11px;
    padding: .2em 1em .275em;
}


/* blue */
.blue {
    color: #d9eef7;
    border: solid 1px #0076a3;
    background: #0095cd;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#00adee), to(#0078a5));
    background: -moz-linear-gradient(top,  #00adee,  #0078a5);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr=
    &#39;#00adee&#39;, endColorstr=&#39;#0078a5&#39;);
}
.blue:hover {
    background: #007ead;
    background: -webkit-gradient(linear, left top, left bottom, 
    from(#0095cc), to(#00678e));
    background: -moz-linear-gradient(top,  #0095cc,  #00678e);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr=
    &#39;#0095cc&#39;, endColorstr=&#39;#00678e&#39;);
}
.blue:active {
    color: #80bed6;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#0078a5), to(#00adee));
    background: -moz-linear-gradient(top,  #0078a5,  #00adee);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr=
    &#39;#0078a5&#39;, endColorstr=&#39;#00adee&#39;);
}

/* green */
.green {
    color: #e8f0de;
    border: solid 1px #538312;
    background: #64991e;
    background: -webkit-gradient(linear, left top, left bottom, 
    from(#7db72f), to(#4e7d0e));
    background: -moz-linear-gradient(top,  #7db72f,  #4e7d0e);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#7db72f&#39;, endColorstr=&#39;#4e7d0e&#39;);
}
.green:hover {
    background: #538018;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#6b9d28), to(#436b0c));
    background: -moz-linear-gradient(top,  #6b9d28,  #436b0c);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#6b9d28&#39;, endColorstr=&#39;#436b0c&#39;);
}
.green:active {
    color: #a9c08c;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#4e7d0e), to(#7db72f));
    background: -moz-linear-gradient(top,  #4e7d0e,  #7db72f);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#4e7d0e&#39;, endColorstr=&#39;#7db72f&#39;);
}

/* white */
.white {
    color: #606060;
    border: solid 1px #b7b7b7;
    background: #fff;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#fff), to(#ededed));
    background: -moz-linear-gradient(top,  #fff,  #ededed);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#ffffff&#39;, endColorstr=&#39;#ededed&#39;);
}
.white:hover {
    background: #ededed;
    background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dcdcdc));
    background: -moz-linear-gradient(top,  #fff,  #dcdcdc);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#ffffff&#39;, endColorstr=&#39;#dcdcdc&#39;);
}
.white:active {
    color: #999;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#ededed), to(#fff));
    background: -moz-linear-gradient(top,  #ededed,  #fff);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#ededed&#39;, endColorstr=&#39;#ffffff&#39;);
}

/* orange */
.orange {
    color: #fef4e9;
    border: solid 1px #da7c0c;
    background: #f78d1d;
    background: -webkit-gradient(linear, left top, left bottom,
     from(#faa51a), to(#f47a20));
    background: -moz-linear-gradient(top,  #faa51a,  #f47a20);
    filter:  progid:DXImageTransform.Microsoft.gradient(
    startColorstr=&#39;#faa51a&#39;, endColorstr=&#39;#f47a20&#39;);
}
.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=&#39;#f88e11&#39;, endColorstr=&#39;#f06015&#39;);
}
.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=&#39;#f47a20&#39;, endColorstr=&#39;#faa51a&#39;);
}
</style>
</head>

<body>
<div class="demo">
        <a href="#" class="button blue">蓝色</a>
        <a href="#" class="button blue bigrounded">Rounded</a>
        <a href="#" class="button blue medium">Medium</a>
        <a href="#" class="button blue small">Small</a>
       
        <input class="button blue" type="button" value="Input Element" />
        <button class="button blue">Button Tag</button>
    </div>
   
    <div class="demo">
        <a href="#" class="button green">绿色</a>
        <a href="#" class="button green bigrounded">Rounded</a>
        <a href="#" class="button green medium">Medium</a>
        <a href="#" class="button green small">Small</a>
       
        <input class="button green" type="button" value="Input Element" />
        <button class="button green">Button Tag</button>
    </div>
   
    <div class="demo">
        <a href="#" class="button white">灰白</a>
        <a href="#" class="button white bigrounded">Rounded</a>
        <a href="#" class="button white medium">Medium</a>
        <a href="#" class="button white small">Small</a>
        <input class="button white" type="button" value="Input Element" />
        <button class="button white">Button Tag</button>
    </div>
   
    <div class="demo">
        <a href="#" class="button orange">橘红</a>
        <a href="#" class="button orange bigrounded">Rounded</a>
        <a href="#" class="button orange medium">Medium</a>
        <a href="#" class="button orange small">Small</a>
        <input class="button orange" type="button" value="Input Element" />
        <button class="button orange">Button Tag</button>
    </div>
</body>
</html>
Salin selepas log masuk




Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan