✨ 想要的效果:
🦭 代码示例:
<!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>
.card-animation {
width: 100px;
height: 100px;
background-color: skyblue;
position: absolute;
top: 100px;
/* left: 10px; */
right: 10px;
transition: width 0.5s, transform 0.5s;
}
.card-animation:hover {
width: calc(90%);
}
</style>
</head>
<body>
<div>
<div class="card-animation"></div>
</div>
</body>
</html>
⭐️ 关键点:
如果card-animation这个类名里的属性设置right的话就是从右边向左边。
如果设置的是left的话就是从左边向右边