一个hover效果
之前一直都有搜集一些好玩的css效果,今天在TDF上前端页面用了一下,一个简单的css效果可能让你“眼前一亮”,:neckbeard:夸张了夸张了。
先上效果图
上代码(可以直接粘贴使用哦)
html代码
<a
href="http://tech.taiji.com.cn/tdfcloud/"
style="color: #fff;text-decoration:none"
target="_blank"
class="draw-border"
><button>HOVER ME</button>
</a>
css代码
#draw-border {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
button {
border: 0;
background: none;
text-transform: uppercase;
color: #fff;
font-weight: bold;
position: relative;
outline: none;
padding: 10px 20px;
box-sizing: border-box;
}
button::before,
button::after {
box-sizing: inherit;
position: absolute;
content: "";
border: 2px solid transparent;
width: 0;
height: 0;
}
button::after {
bottom: 0;
right: 0;
}
button::before {
top: 0;
left: 0;
}
button:hover::before,
button:hover::after {
width: 100%;
height: 100%;
}
button:hover::before {
border-top-color: #1890ff;
border-right-color: #1890ff;
transition: width 0.3s ease-out, height 0.3s ease-out 0.3s;
}
button:hover::after {
border-bottom-color: #1890ff;
border-left-color: #1890ff;
transition: border-color 0s ease-out 0.6s, width 0.3s ease-out 0.6s,
height 0.3s ease-out 1s;
}
效果2
html代码
<div id="border-btn">
<button>Hover me</button>
</div>
css代码
<style lang="scss">
#border-btn {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
button {
border: 0;
border-radius: 10px;
background: #2ec4b6;
text-transform: uppercase;
color: white;
font-size: 16px;
font-weight: bold;
padding: 15px 30px;
outline: none;
position: relative;
transition: border-radius 3s;
-webkit-transition: border-radius 3s;
}
button:hover {
border-bottom-right-radius: 50px;
border-top-left-radius: 50px;
border-bottom-left-radius: 10px;
border-top-right-radius: 10px;
}
</style>
前端路漫漫其修远兮,吾将上下而求索,一起加油,学习前端吧:stuck_out_tongue_closed_eyes:~