
BUTTONS-V2-CSS库样式职责
CSS库样式职责分离优点
模块样式命名更清晰化
易于维护、扩展性强
动画效果——修改样式后有过度效果,默认样式
源码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Buttons库学习</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
font-family: "microsoft yahei"; }
a {
text-decoration: none;
outline: none;
}
/*
* Base Button Style
*
* The default values for the .button class
*/
.button {
color: #666;
background-color: #EEE;
border-color: #EEE;
font-weight: 300;
font-size: 16px;
font-family: "microsoft yahei","Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
text-decoration: none;
text-align: center;
line-height: 40px;
height: 40px;
padding: 0 56px;
margin: 10px;
display: inline-block;
appearance: none;
cursor: pointer;
border: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: .3s;
transition-duration: .3s; } .button-large {
font-size: 20px;
height: 45px;
line-height: 45px;
padding: 0 45px; } /*
* Button Shapes
*
* This file creates the various button shapes
* (ex. Circle, Rounded, Pill)
*/
.button-rounded {
border-radius: 4px; }
/*
* Raised Buttons
*
* A classic looking button that offers
* great depth and affordance.
*/
.button-raised {
border-color: #e1e1e1;
border-style: solid;
border-width: 1px;
line-height: 38px;
background: -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#e1e1e1));
background: linear-gradient(#f6f6f6, #e1e1e1);
-webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.15);
box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.15); }
.button-raised:hover, .button-raised:focus {
background: -webkit-gradient(linear, left top, left bottom, from(white), to(gainsboro));
background: linear-gradient(top, white, gainsboro); }
.button-raised:active, .button-raised.active, .button-raised.is-active {
background: #eeeeee;
-webkit-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.2), 0px 1px 0px white;
box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.2), 0px 1px 0px white; } /*
* Base Colors
*
* Create colors for buttons
* (.button-primary, .button-secondary, etc.)
*/
.button-primary:hover, .button-primary:focus{
background-color: #4cb0f9;
border-color: #4cb0f9;
color: #FFF; } /*
* Raised Button Colors
*
* Create colors for raised buttons
*/
.button-raised.button-primary {
border-color: #088ef0;
background: -webkit-gradient(linear, left top, left bottom, from(#34a5f8), to(#088ef0));
background: linear-gradient(#34a5f8, #088ef0); }
.button-raised.button-primary:hover, .button-raised.button-primary:focus {
background: -webkit-gradient(linear, left top, left bottom, from(#42abf8), to(#0888e6));
background: linear-gradient(top, #42abf8, #0888e6); } .button-highlight {
background-color: #FEAE1B;
border-color: #FEAE1B;
color: #FFF; }
.button-highlight:hover, .button-highlight:focus {
background-color: #fec04e;
border-color: #fec04e;
color: #FFF; } </style>
</head>
<body>
<a href="#none" class="button button-raised button-primary">GO</a>
<a href="#none" class="button button-large button-highlight button-rounded">Default-CSS</a>
</body>
</html>