为按钮元素添加before伪元素,想让伪元素宽高与按钮一致,设置100%后发现伪元素宽高与窗口相同,如何设置才能使其宽高与按钮一致?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.animated{
padding: 5px 10px;
border: 1px solid #f08c41;
color: #f08c41;
background-color: white;
}
.animated::before{
content: "";
background-color: #f08c41;
display: block;
position: absolute;
width: 100%;
height: 100%;
z-index: 5;
}
</style>
</head>
<body>
<button class="animated">Contact Us Now!</button>
</body>
</html>