html5 按钮渐变效果图,纯CSS3超酷彩色3D按钮样式

这篇博客介绍了如何利用CSS3的线性渐变特性制作一系列彩色、不同尺寸和圆角的3D按钮。通过添加特定的class,可以轻松实现各种样式。详细展示了按钮的基础CSS样式,包括hover和active状态的样式调整,以及文字颜色和阴影效果。此外,还提供了按钮尺寸(大型、中型、小型)、圆角(常规、方形、圆形)和颜色(红、橙、黄、绿、蓝、紫、白、灰、黑)的CSS定义。
摘要由CSDN通过智能技术生成

这是一款使用使用CSS3 线性渐变来制作的超酷彩色3D按钮样式。这组按钮分为不同的颜色,尺寸和圆角,使用时只需要添加相应的class类即可,简单实用。

使用方法

HTML结构

按钮的基本HTML结构非常简单,使用一个超链接元素来制作。

Button

CSS样式

按钮的通用CSS样式如下。

.button {

background-color: #999;

background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));

background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));

background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));

background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));

background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));

border: none;

border-radius: .5em;

box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.2),

inset 0 2px 0 hsla(0,0%,100%,.1),

inset 0 1.2em 0 hsla(0,0%,100%,0.1),

inset 0 -.2em 0 hsla(0,0%,100%,.1),

inset 0 -.25em 0 hsla(0,0%,0%,.25),

0 .25em .25em hsla(0,0%,0%,.05);

color: #444;

cursor: pointer;

display: inline-block;

font-family: sans-serif;

font-size: 1em;

font-weight: bold;

line-height: 1.5;

margin: 0 .5em 1em;

padding: .5em 1.5em .75em;

position: relative;

text-decoration: none;

text-shadow: 0 1px 1px hsla(0,0%,100%,.25);

vertical-align: middle;

}

.button:hover {

outline: none;

}

.button:hover,

.button:focus {

box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.2),

inset 0 2px 0 hsla(0,0%,100%,.1),

inset 0 1.2em 0 hsla(0,0%,100%,.1),

inset 0 -.2em 0 hsla(0,0%,100%,.1),

inset 0 -.25em 0 hsla(0,0%,0%,.25),

inset 0 0 0 3em hsla(0,0%,100%,.2),

0 .25em .25em hsla(0,0%,0%,.05);

}

.button:active {

box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.2),

inset 0 2px 0 hsla(0,0%,100%,.1),

inset 0 1.2em 0 hsla(0,0%,100%,.1),

inset 0 0 0 3em hsla(0,0%,100%,.2),

inset 0 .25em .5em hsla(0,0%,0%,.05),

0 -1px 1px hsla(0,0%,0%,.1),

0 1px 1px hsla(0,0%,100%,.25);

margin-top: .25em;

outline: none;

padding-bottom: .5em;

}

按钮上的文本样式如下。

.lightText {

box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.25),

inset 0 2px 0 hsla(0,0%,100%,.1),

inset 0 1.2em 0 hsla(0,0%,100%,.05),

inset 0 -.2em 0 hsla(0,0%,100%,.1),

inset 0 -.25em 0 hsla(0,0%,0%,.5),

0 .25em .25em hsla(0,0%,0%,.1);

color: #fff;

text-shadow: 0 -1px 1px hsla(0,0%,0%,.25);

}

.lightText:hover,

.lightText:focus {

box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.25),

inset 0 2px 0 hsla(0,0%,100%,.1),

inset 0 1.2em 0 hsla(0,0%,100%,.05),

inset 0 -.2em 0 hsla(0,0%,100%,.1),

inset 0 -.25em 0 hsla(0,0%,0%,.5),

inset 0 0 0 3em hsla(0,0%,100%,.2),

0 .25em .25em hsla(0,0%,0%,.1);

}

.lightText:active {

box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.25),

inset 0 2px 0 hsla(0,0%,100%,.1),

inset 0 1.2em 0 hsla(0,0%,100%,.05),

inset 0 0 0 3em hsla(0,0%,100%,.2),

inset 0 .25em .5em hsla(0,0%,0%,.05),

0 -1px 1px hsla(0,0%,0%,.1),

0 1px 1px hsla(0,0%,100%,.25);

}

按钮的各种尺寸,圆角和颜色的CSS样式如下。

/* Large */

.large {font-size: 1.25em;}

/* Medium */

.medium {font-size: 1em;}

/* Small */

.small {font-size: .75em;}

/* Regular */

.regular {border-radius: .5em;}

/* Square */

.square {border-radius: .25em;}

/* Round */

.round {border-radius: 1.25em;}

/* Red */

.red {background-color: #ff6c6f;}

/* Orange */

.orange {background-color: #f6cf6f;}

/* Yellow */

.yellow {background-color: #fff6c6;}

/* Green */

.green {background-color: #6fcf6f;}

/* Blue */

.blue {background-color: #6fc6ff;}

/* Purple */

.purple {background-color: #f6c6ff;}

/* White */

.white {background-color: #eee;}

/* Grey */

.grey {background-color: #999;}

/* Black */

.black {background-color: #444;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值