어떻게div의 배경색이 왼쪽에서 오른쪽으로 천천히 나타나는 것을 실현합니까?
여기서 위류를 소개합니다:after<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.btn button {
position: relative;
}
.btn button::after {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
transition: .3s;
opacity: .3;
background: #000;
transform-origin: left;
transform: scaleX(0);
}
.btn button:hover::after {
transform: scaleX(1);
}
.btn button{
background-color: red;
width: 200px;
height: 40px;
border: none;
outline: none;
cursor: pointer;
color: white;
}
</style>
</head>
<body>
<div class="btn">
<button> </button>
</div>
</html>