老师检查一下代码
来源:4-3 编程练习
ShanaZ
2019-03-18 22:37:21
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.page{
width: 100%;
height: 4020px;
background:url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) center top no-repeat;
}
.left{
width: 100%;
height: 400px;
background: url(http://climg.mukewang.com/5a3383c70001f1b702240364.png) left no-repeat;
position: fixed;
left:0;
top: 50%;
margin-top:-200px;
}
.right{
width: 100%;
height: 400px;
background: url(http://climg.mukewang.com/5a3383d00001a3dd02240364.png) right center no-repeat;
position: fixed;
left:0;
top: 50%;
margin-top:-200px;
}
</style>
</head>
<body>
<div class="page">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>我想问下广告的height设置成100%或者 width设置成auto为什么不行呢
1回答
Steve007
2019-03-19
同学,你好。效果实现的不错,代码也比较规范,广告的height设置成100%之后,它就会继承body的高,随着body的高发生变化,广告的高也会发生变化,因此不需要设置定位的top值,和margin-top样式也是可以实现效果的,如图:

祝学习愉快!
相似问题