使用CSS实现点击按钮出现气泡
100人浏览 2024-08-28 08:18:19
效果图:

- 所有代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.btn {
width: 200px;
height: 50px;
background-color: orange;
margin: 50px auto;
text-align: center;
line-height: 50px;
position: relative;
}
.bubble {
/* 气泡定位在按钮的正中间 */
position: absolute;
right: 0px;
left: 0px;
top: 0px;
bottom: 0px;
margin: auto;
width: 200px;
height: 200px;
background: #fff;
border-radius: 50%;
transform: scale(1);
opacity: 0;
transition: all 0.5s;
}
.btn:active .bubble {
opacity: 1;
transform: scale(0);
/*
鼠标点击,然后bubble的缩放为0,透明度为1,transition给0是因为让整个过程瞬发
由于动作触发完成后,会恢复原状,因此看到扩张的效果
其实过程是:点击的一瞬间气泡缩放为0透明度为1,然后经过0.5s后缩放为1,透明度为0
就出现了扩张的效果
*/
transition: 0s;
}
</style>
</head>
<body>
<div class="btn">
click
<div class="bubble"></div>
</div>
</body>
</html>

相关推荐
-
mac php 启用intl 苦难记2025-04-28 01:22:11
-
PHP实现异步调用的方式2025-04-28 01:11:52
-
Nginx安全相关配置常用教程2025-04-28 00:42:40
-
php http PHP的HTTP验证2025-04-28 00:21:22
-
DBA技术分享(一)-MYSQL常用查询Databases和tables
DBA技术分享(一)-MYSQL常用查询Databases和tables2025-04-27 02:23:34