老师右侧的广告用right定位不准是什么原因?
来源:4-3 编程练习
慕数据1457773
2019-07-09 15:12:41
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{margin:0;padding:0;}
.main{width:100%;height:4500px;background:url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) center top no-repeat;position:relative;}
.left{background:url(http://climg.mukewang.com/5a3383c70001f1b702240364.png) no-repeat;position:fixed; top:50%;margin-top:-100px;left:0;width:300px; height:200px;}
.right{background:url(http://climg.mukewang.com/5a3383d00001a3dd02240364.png) no-repeat;position:fixed;top:50%;margin-top:-100px;left:85%;width:300px; height:200px;}
</style>
</head>
<body>
<div class="main">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>
1回答
好帮手慕慕子
2019-07-09
同学你好, 造成这种现象的原因有两个,如下
使用left设置定位,导致计算不准确, 建议:直接使用right:0;属性,让右侧的广告在最右侧显示
盒子的宽度设置的太大, 导致图片没有铺满整个容器, 右侧出现空白, 建议: 可以适当调整右侧盒子的宽度
参考代码示例:

同学可以自己下去在测试一下
如果帮助到了你, 欢迎采纳!
祝学习愉快~~~
相似问题