css的clip path实现按钮点击动画效果代码
代码语言:html
所属分类:布局界面
代码描述:css的clip path实现按钮点击动画效果代码,现代浏览器支持。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css2?family=PT+Mono&family=Poppins:wght@400;600&display=swap");
body {
background-color: #20232e;
color: #a1b1e6;
font-family: "Poppins", sans-serif;
font-weight: 400;
}
h1,
h2 {
font-weight: 600;
}
h1 span,
h2 span {
color: #fcba03;
font-family: "PT Mono", monospace;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
min-height: 100vh;
}
.row {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.box {
background-color: #2e3342;
border: 1px solid #444b61;
border-radius: 6px;
margin: 10px;
padding: 10px 30px;
}
button {
align-items: center;
background: none;
border: none;
color: #fff;
cursor: pointer;
display: flex;
font-family: "Poppins", sans-serif;
font-size: 18px;
height: 44px;
margin: 15px 0;
padding: 0 25px;
position: relative;
text-decoration: none;
z-index: 1;
}
button:before, button:after {
border-radius: 50px;
content: "";
display: block;
left: 0;
position: absolute;
top: 0;
width: 100%;
height: 100%;
z-index: -1;
transition: -webkit-clip-path 275ms ease-in-out;
transition: clip-path 275ms ease-in-out;
transition: clip-path 275ms ease-in-out, -webkit-clip-path 275ms ease-in-out;
}
button.dramatic:before, button.dramatic:after {
transition: none;
}
button:before {
background: #33383b;
background: linear-gradient(60deg, #3a3e52 0%, #606788 100%);
box-shadow: -1px 1px 1px 0px #808dcb inset, 0px 0px 0px 4px rgba(14, 16, 20, 0.7);
}
button:after {
background: #a53ab4;
background: linear-gradient(90deg, #a53ab4 0%, #f45757 100%);
box-shadow: -1px 1px 1px 0px #f79393 inset, 0px 0px 0px 4px rgba(14, 16, 20, 0.7);
}
button.left-to-right:after {
-webkit-clip-path: inset(0 100% 0 0);
clip-path: inset(0 100% 0 0);
}
button.left-to-right:focus:after {
-webkit-clip-path: inset(0 0 0 0);
clip-path: inset(0 0 0 0);
}
button.center-out-y:after {
-webkit-clip-path: inset(50% 0 50% 0);
clip-path: inset(50% 0 50% 0);
}
button.center-out-y:focus:after {
-webkit-clip-path: inset(0 0 0 0);
clip-path: inset(0 0 0 0);
}
button.center-out-x:after {
-webkit-clip-path: inset(0 50% 0 50%);
clip-path: inset(0 50% 0 50%);
}
button.center-out-x:focus:after {
-webkit-clip-path: inset(0 0 0 0);
clip-path: inset(0 0.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0