html部分:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>发光按钮</title>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<div class="container">
<a href="javascript:void(0);">点赞</a>
<a href="javascript:void(0);">评论</a>
<a href="javascript:void(0);">转发</a>
<a href="javascript:void(0);">关注</a>
</div>
</body>
</html>
css部分:
*{
/* 初始化,清除页面元素的内外边距 */
padding: 0;
margin: 0;
}
.container{
/* 弹性元素 让页面元素垂直水平居中 */
display: flex;
justify-content: center;
align-items: center;
/* 子元素垂直排列 */
flex-direction: column;
/* 宽站浏览器可视窗口总宽度 */
width: 100 vm;
height: 100vh;
background-color: #000000;
}
.container a{
/* 相对定位 */
position: relative;
/* 将行内元素转化成块级元素 不然无法设置宽高 */
display: block;
width: 140px;
height: 60px;
/* 行高 */
line-height: 60px;
text-align: center;
margin: 40px;
color: aquamarine;
font-size: 20px;
text-decoration: none;
transition: all 0.5s ease-in-out;
/* filter: hue-rotate(calc(var(--i)*60deg)); */
}
.container a::before,.container a::after{
/*将伪元素的相同部分写在一起 */
content: "";
position: absolute;
width: 20px;
height: 20px;
border: 1px solid aquamarine;
transition: all 0.5s ease-in-out;
}
.container a::before{
top: 0;
left: 0;
/* 删除左边的伪元素的右边和下边边框 */
border-bottom: 0;
border-right: 0;
}
.container a::after{
right: 0;
bottom: 0;
/* 删除右边伪元素的上边和左边的边框 */
border-top: 0;
border-left: 0;
}
.container a:hover{
background-color: aquamarine;
color: #000000;
/* 加发光效果和下面的倒影 模糊度加到50px */
box-shadow: 0 0 50px aquamarine;
-webkit-box-reflect: below 1px
linera-gradient(transparent,rgba(0,0,0,.3));
/* below是下倒影 1px是倒影的元素相隔的距离 最后时渐变的颜色*/
transition-delay: 0.4s;
}
效果图: