1.代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>网页title</title>
<style>
/*---范例1:按钮边框颜色样式---*/
button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button2 {
background-color: white;
color: black;
border: 2px solid #008CBA;
}
.button3 {
background-color: white;
color: black;
border: 2px solid #f44336;
}
.button4 {
background-color: white;
color: black;
border: 2px solid #e7e7e7;
}
.button5 {
background-color: white;
color: black;
border: 2px solid #555555;
}
/*---鼠标悬停按钮样式---*/
.button1:hover {background-color: #4CAF50; color: white;}
.button2:hover {background-color: #008CBA; color: white;}
.button3:hover {background-color: #f44336; color: white;}
.button4:hover {background-color: #e7e7e7; color: white;}
.button5:hover {background-color: #555555; color: white;}
/*---范例2:按钮阴影样式---*/
.button6 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
.button7 {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.button8:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
}
/*---范例3:禁用按钮--*/
.button9 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.disabled {
opacity: 0.6;
cursor: not-allowed;
}
/*---范例4:按钮宽度--*/
.button10 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button11 {width: 250px;}
.button12 {width: 50%;}
.button13 {
padding-left: 0;
padding-right: 0;
width: 100%;
}
</style>
</head>
<body>
<p>范例1:按钮边框颜色+鼠标悬停按钮样式</p>
<button class="button button1">Green</button>
<button class="button button2">Blue</button>
<button class="button button3">Red</button>
<button class="button button4">Gray</button>
<button class="button button5">Black</button>
<p>范例2:按钮阴影样式</p>
<button class="button6 button7">阴影按钮</button>
<button class="button6 button8">鼠标悬停后出现阴影</button>
<p>范例3:禁用按钮样式</p>
<button class="button9">正常按钮</button>
<button class="button9 disabled">禁用按钮</button>
<p>范例4:按钮宽度</p>
<button class="button10 button11">250px</button><br>
<button class="button10 button12">50%</button><br>
<button class="button10 button13">100%</button>
</body>
</html>
2.结果: