一款简单大气的纯CSS按钮悬停特效,虽然只有两种效果,但整体特效比较流畅、色彩也比较大气,所以给各位童鞋推荐一下。当然了,色彩和动画特效都可以自由调整的。
页面的head部分设置好CSS样式,请注意一下:before、:after和:hover之类的CSS选择器,transform: translateY(-10px);这类的可以自行尝试调整效果的,完整CSS代码如下:
body {
background: #2D2D34;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
}
.box {
position: relative;
width: 120px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
margin: 15px;
color: #F27059;
}
.item {
text-transform: uppercase;
letter-spacing: 2px;
font-size: 14px;
z-index: 99;
display: flex;
justify-content: center;
align-items: center;
transition: 0.4s all ease;
}
.one:before, .one:after {
position: absolute;
content: '';
width: 100%;
height: 2px;
background: #F27059;
transition: 0.4s all ease;
}
.one:before {
top: 0;
}
.one:after {
bottom: 0;
}
.one .item:before, .one .item:after {
position: absolute;
top: 0;
content: '';
height: 100%;
width: 2px;
background: #F27059;
transition: 0.4s all ease;
z-index: -1;
}
.one .item:before {
left: 0;
}
.one .item:after {
right: 0;
}
.one:hover:before, .one:hover:after {
transition: 0.4s all ease;
}
.one:hover:before {
transform: translateY(-10px);
}
.one:hover:after {
transform: translateY(10px);
}
.one:hover .item {
color: white;
}
.one:hover .item:before, .one:hover .item:after {
width: 100%;
transition: 0.4s all ease;
}
.two {
box-sizing: border-box;
border: 2px solid #F27059;
position: relative;
}
.two:before {
position: absolute;
content: '';
width: 0;
height: 50px;
transition: 0.4s all ease;
background: #F27059;
left: 0;
z-index: -1;
}
.two:hover {
color: white;
}
.two:hover:before {
width: 100%;
transition: 0.4s all ease;
}
页面的body部分比较简单,两个div容器存放不同的按钮即可,代码如下:
<div class="box one">
<div class="item">上下描边</div>
</div>
<div class="box two">
<div class="item">左侧滑入</div>
</div>
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791