原理:控制margin数值
图片.png
效果:
鼠标移动上去:不知道为什么录屏没有鼠标
小米.gif
<!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>
.box1 {
width: 55px;
height: 55px;
background-color: orange;
overflow: hidden;
margin: 100px auto;
}
.logo::after,
.logo::before {
width: 100%;
height: 100%;
line-height: 55px;
font-size: 54px;
transition: all 0.3s;
}
.logo::before {
content: "mi";
}
.logo::after {
content: "ho";
margin-left: 55px;
}
.box1 .logo:hover::after {
margin-left: 0;
}
.box1 .logo:hover::before {
margin-left: -55PX;
}
</style>
</head>
<body>
<div class="box1">
<div class="logo"></div>
</div>
</body>
</html>
本文复习了
overflow 文本溢出
伪元素
transition
网友评论