效果是实现了 但是还是有个小问题
来源:4-3 编程练习
慕哥2455504
2019-08-06 14:29:45
效果是实现了,但是在放入页面背景图片的时候,如果设置宽为100%,高设置个4043px的话 给那个背景图片就会不完全显示,最后调整高度达到了效果,想问一下老师,还有其他方法可以实现吗?
<!DOCTYPE html>
<html>
<head>
<title>广告练习</title>
<meta charset="utf-8">
<style type="text/css">
.page{
width:100%;
height:3050px;
background-image:url("http://climg.mukewang.com/59c9f7ce0001839219034033.png");
background-repeat:no-repeat;
margin:auto;
position:relative;
}
.ad1{
width:250px;
height:300px;
background-image:url("http://climg.mukewang.com/5a3383d00001a3dd02240364.png");
background-repeat:no-repeat;
position:fixed;
left:135px;
top:50%;
margin-top:-150px;
}
.ad2{
width:250px;
height:300px;
background-image:url("http://climg.mukewang.com/5a3383c70001f1b702240364.png");
background-repeat:no-repeat;
position:fixed;
right:88px;
top:50%;
margin-top:-150px;
}
</style>
</head>
<body>
<div class="page">
<div class="ad1"></div>
<div class="ad2"></div>
</div>
</body>
</html>
1回答
同学你好, 整体效果实现了, 不过, 练习效果要求左右侧要贴着窗口显示哦, 你这里的左右距离窗口有空白距离。
建议: 可以设置左右广告的left和right值为0 , 另, 可以调整宽度, 让背景图片刚好铺满整个容器
因为背景图片是需要根据盒子的大小来决定显示的范围,目前没有其他方法更好的办法解决,这道练习主要是考察大家对背景图片的掌握情况哦, 同学这种实现的方法已经很棒了,
如果帮助到了你, 欢迎采纳!
祝学习愉快~~~
相似问题