老师,这样写可以吗?跟老师用伪元素写法哪个更好?有没有需要优化的地方?
来源:2-10 过渡效果实战课(2)
weixin_慕码人7523200
2020-11-04 22:18:43
# 具体遇到的问题
# 报错信息的截图
# 相关课程内容截图
# 尝试过的解决思路和结果
# 粘贴全部相关代码,切记添加代码注释(请勿截图)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
width: 578px;
height: 107px;
margin: 100px auto;
}
.box ul {
list-style: none;
overflow: hidden;
}
.box ul li {
float: left;
}
.box ul li+li {
margin-left: 50px;
}
.box ul li .img-box {
position: relative;
width: 107px;
height: 107px;
}
.box ul li .img-box .front {
position: absolute;
width: 50px;
height: 50px;
top: 50%;
margin-top: -25px;
left: 50%;
margin-left: -25px;
transition: transform .5s ease 0s;
}
.box ul li .img-box:hover .front {
transform: scale(1.2);
}
.box ul li .img-box .behind {
transition: transform .5s ease 0s;
}
.box ul li .img-box:hover .behind {
transform: rotateZ(360deg);
}
</style>
</head>
<body>
<div class="box">
<ul>
<li>
<div class="img-box">
<img class="behind" src="../images/a_1.png" alt="">
<img class="front" src="../images/icon1.svg" alt="">
</div>
</li>
<li>
<div class="img-box">
<img class="behind" src="../images/a_2.png" alt="">
<img class="front" src="../images/icon2.svg" alt="">
</div>
</li>
<li>
<div class="img-box">
<img class="behind" src="../images/a_3.png" alt="">
<img class="front" src="../images/icon3.svg" alt="">
</div>
</li>
<li>
<div class="img-box">
<img class="behind" src="../images/a_4.png" alt="">
<img class="front" src="../images/icon4.svg" alt="">
</div>
</li>
</ul>
</div>
</body>
</html>
1回答
同学你好,代码效果实现了哦,代码也写的简练;实现效果的方式不是唯一的,同学的方法也很好哦,非常棒,继续加油呀!
祝学习愉快!
相似问题
回答 2