1.less
* {
margin: 0;
padding: 0;
body {
a {
//a标签不可以设置宽高,需要display:inline-block
display: inline-block;
//未知宽高下居中使用trnasform:translate(x,y)
width: 100px;
height: 30px;
//原本装饰样式decoration为none
text-decoration: none;
position: absolute;
background: skyblue;
text-align: center;
font: 20px/30px "微软雅黑";
font-weight: bold;
color: white;
border: 1px solid darkcyan;
//阴影:box-shadow:x-px , y-px ,模糊程度?px #color
box-shadow: 2px 2px 5px #4682B4;
top: 50%;
left: 50%;
//定位点在元素自身的宽高--》兼容性不高
transform: translate(-50%, -50%);
margin: auto;
transition: 1.5s;
}
&:hover a {
color: white;
background: steelblue;
}
}
}
2.css
* {
margin: 0;
padding: 0;
}
* body a {
display: inline-block;
width: 100px;
height: 30px;
text-decoration: none;
position: absolute;
background: skyblue;
text-align: center;
font: 20px/30px "微软雅黑";
font-weight: bold;
color: white;
border: 1px solid darkcyan;
box-shadow: 2px 2px 5px #4682B4;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: auto;
transition: 1.5s;
}
* body:hover a {
color: white;
background: steelblue;
}
3.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>light button高亮按钮</title>
</head>
<body>
<a href="javascript:;">Home</a>
</body>
<link rel="stylesheet" href="css/less024.css" />
</html>
4.效果图
![cevent](https://i-blog.csdnimg.cn/blog_migrate/a7ac6a2e51b04ea9689c4c0a6439185a.gif)