代码示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="./index.css">
<style>
.btn{
text-decoration: none;
border: solid 5px orange;
position: relative;
overflow: hidden;
}
.btn::after{
content: '';
width: 0;
height: 100%;
position: absolute;
transform: skewX(45deg);
background-color: #8A2BE2;
left: -50%;
z-index: -1;
transition:.5s;
}
.btn:hover::after{
width: 200%;
}
</style>
</head>
<body class='me'>
<div class='box'>
<a href="" class='btn'>按钮</a>
</div>
</body>
</html>
效果图: