1 Star 0 Fork 0

小先生/波纹按钮

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
波纹按钮.html 3.89 KB
一键复制 编辑 原始数据 按行查看 历史
小先生 提交于 2021-08-18 14:16 . 提交波纹按钮
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100vh;
background: #282c34;
display: flex;
justify-content: center;
align-items: center;
}
.btn-box {
width: 800px;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.box {
position: relative;
width: 250px;
height: 125px;
border-radius: 10px;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
color: white;
text-align: center;
user-select: none;
margin: 5px;
box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.2);
}
.box:nth-of-type(1) {
background: linear-gradient(150deg,
rgb(251, 122, 8),
rgb(240, 47, 31));
}
.box:nth-of-type(2) {
background: linear-gradient(150deg,
rgb(241, 43, 84),
rgb(237, 11, 125));
}
.box:nth-of-type(3) {
background: linear-gradient(150deg,
rgb(65, 182, 73),
rgb(125, 195, 65));
}
.box:nth-of-type(4) {
background: linear-gradient(150deg,
rgb(5, 141, 239),
rgb(22, 175, 194));
}
.box:nth-of-type(5) {
background: linear-gradient(150deg,
rgb(134, 0, 255),
rgb(103, 0, 255));
}
.box:nth-of-type(6) {
background: linear-gradient(150deg,
rgb(209, 11, 148),
rgb(113, 52, 178));
}
.ripple {
display: block;
position: absolute;
border-radius: 100%;
background: rgba(255, 255, 255, 0.5);
transform: scale(0);
}
.animation {
animation: ripple 0.5s ease-in;
}
@keyframes ripple {
100% {
transform: scale(3);
opacity: 0;
}
}
</style>
</head>
<body>
<div class="btn-box">
<div class="box">
<span class="ripple"></span>
<p>鎏金</p>
</div>
<div class="box">
<span class="ripple"></span>
<p>魅红</p>
</div>
<div class="box">
<span class="ripple"></span>
<p>翠柳</p>
</div>
<div class="box">
<span class="ripple"></span>
<p>靛青</p>
</div>
<div class="box">
<span class="ripple"></span>
<p>惑紫</p>
</div>
<div class="box">
<span class="ripple"></span>
<p>霞彩</p>
</div>
</div>
<script>
let box = document.querySelectorAll(".box");
for (let i = 0; i < box.length; i++) {
box[i].onmouseenter = function (event) {
let ripple = box[i].querySelector(".ripple");
ripple.classList.add("animation");
ripple.style.width = this.offsetWidth + "px";
ripple.style.height = this.offsetWidth + "px";
ripple.style.top = -(this.offsetHeight - event.offsetY) + "px";
ripple.style.left = -(this.offsetWidth / 2 - event.offsetX) + "px";
setTimeout(function () {
ripple.classList.remove("animation");
}, 500)
}
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wjj_xiaoxiansheng/corrugated-button.git
[email protected]:wjj_xiaoxiansheng/corrugated-button.git
wjj_xiaoxiansheng
corrugated-button
波纹按钮
master

搜索帮助