老师请检查
来源:4-3 编程练习
慕勒9893359
2019-04-04 07:19:19
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
<style type="text/css">
*{
padding: 0;
margin: 0;
}
html,body{
width: 100%;
height: 100%;
}
.web{
width: 100%;
height:4000px;
background: url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) top center no-repeat;
}
.ads1{
width: 224px;
height: 364px;
background: url(http://climg.mukewang.com/5a3383c70001f1b702240364.png);
position: fixed;
top: 50%;
left:0;
margin-top: -180px;
}
.ads2{
width: 224px;
height: 364px;
background: url(http://climg.mukewang.com/5a3383d00001a3dd02240364.png) top center no-repeat;
position: fixed;
top: 50%;
right: 0;
margin-top: -180px;
}
</style>
</head>
<body>
<div class="web">
<div class="ads1"></div>
<div class="ads2"></div>
</div>
</body>
</html>1回答
好帮手慕码
2019-04-04
同学你好!代码效果实现很好~
但是注意:设置了绝对定位之后,想要设置垂直居中应该是: top:50%; +margin-top设置负的元素高度的一半

如果解决了你的疑惑,望采纳, 祝学习愉快~~