使用 CSS 设置悬停效果的速度
cssweb developmentfront end technology更新于 2025/6/28 12:28:17
要设置悬停速度,请使用 transition-duration 属性。要设置悬停,请使用 :hover 选择器。
示例
您可以尝试运行以下代码来加速悬停效果 −
<!DOCTYPE html>
<html>
<head>
<style>
.btn {
background-color: yellow;
color: black;
text-align: center;
font-size: 15px;
padding: 20px;
border-radius: 15px;
border: 3px dashed blue;
transition-duration: 2s;
}
.btn:hover {
background-color: orange;
color: black;
border: 3px solid blue;
}
</style>
</head>
<body>
<h2>Result</h2>
<p>Click below for result:</p>
<button class = "btn">Result</button>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

