<!DOCTYPE html>
<html>
<head>
<style>
.button {
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
.button2 {
background-color: white;
color: black;
border: 2px solid #008CBA;
}
.button2:hover {
background-color: #008CBA;
color: white;
}
</style>
</head>
<body>
<h1>button 元素 - 使用 CSS 设置样式</h1>
<p>当您将鼠标移到按钮上时,使用 :hover 选择器更改按钮的样式。</p>
<p><strong>提示:</strong>使用 transition-duration 属性来确定“悬停”效果的速度:</p>
<button class="button button1">绿色</button>
<button class="button button2">蓝色</button>
</body>
</html>