效果图:
![](https://img-blog.csdnimg.cn/dd31799edbe343bc9917527f8f2c803e.gif)
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>按钮点击</title>
</head>
<style>
body {
background-color: gray;
}
.btn {
width: 100px;
height: 40px;
border: 1px solid #333;
border-radius: 10px;
text-align: center;
line-height: 40px;
font-size: 16px;
color: #fff;
background-color: #096;
margin: 100px auto 20px;
cursor: pointer;
user-select: none;
box-shadow: 1px 1px 5px 0px rgba(50, 50, 50, 0.75);
transition: .2s;
}
/* 按钮点击效果1 */
.btn1 {
transform: scale(1);
}
.btn1:active {
transform: scale(0.97);
}
</style>
<body>
<div class="btn btn1">按钮1</div>
</body>
</html>
下一篇: 如何让一个div上下跳动