如何使用 CSS 创建淡入淡出按钮?
cssweb developmentfront end technology更新于 2025/10/5 1:48:17
以下是使用 CSS 创建淡入淡出按钮的代码 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
button {
background-color: rgb(255, 175, 222);
border: none;
color: black;
padding: 25px;
text-align: center;
font-size: 20px;
margin: 4px 2px;
transition: 0.3s;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-weight: bolder;
}
button:hover {
background-color: #4d0036;
color: white;
}
</style>
</head>
<body>
<h1>Fading Button Example</h1>
<button>Hover Here</button>
<h1>Hover on the above button to see background fade on button</h1>
</body>
</html>
输出
上述代码将产生以下输出 −

鼠标悬停在按钮上时,较暗的背景会淡入 −

相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

