HTML — 淡入淡出边框按钮
效果![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/83b865be1aa30460dc1fdb23a9f85af2.gif#pic_center)
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Tram</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</body>
</html>
CSS
body{
margin: 0;
padding: 0;
font-family: sans-serif;
}
ul{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
margin: 0;
padding: 0;
display: flex;
}
ul li{
list-style: none;
}
ul li a{
position: relative;
display: block;
padding: 10px 20px;
margin: 20px 0;
text-decoration: none;
text-transform: uppercase;
color: #262626;
font-weight: bold;
transition: .5s;
}
ul li a:hover{
color: #fff;
}
ul li a::before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: scaleY(2.5);
border-top: 1px solid #000;
border-bottom: 1px solid #000;
opacity: 0;
transition: .5s;
}
ul li a:hover::before{
transform: scaleY(1.5);
opacity: 1;
}
ul li a::after{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: scale(0);
background-color: #000;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
transition: .5s;
z-index: -1;
}
ul li a:hover::after{
transform: scale(1);
}