麻烦老师批改一下,谢谢~
来源:2-14 编程练习
leiyihai
2019-09-12 16:40:20
一开始尝试用百分比来写,实在搞不定。只好用具体数值来写了。╮(╯_╰)╭
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
padding:0;margin:0;
}
.container{
width:1200px;
height:300px;
background:blue;
margin: 0 auto;
}
.left{
width:360px;
height:215px;
background:url(http://climg.mukewang.com/58c0f808000129a303600215.jpg) no-repeat center center;
float:left;
position: relative;
left: 160px;
top: 50%;
margin-top: -107px;
}
.right{
width:360px;
height:215px;
background:url(http://climg.mukewang.com/58c0f819000198a703600214.jpg) no-repeat center center;
float:right;
position: relative;
right: 160px;
top: 50%;
margin-top: -107px;
}
.footer{
width: 1200px;
height: 100px;
background: pink;
margin:0 auto;
}
.b-left{
width: 200px;
height: 60px;
background: url(http://climg.mukewang.com/58c0f81d0001fe4402000060.jpg) no-repeat center center;
float: left;
position: relative;
left: 150px;
top: 50%;
margin-top: -30px;
}
.b-middle{
width: 200px;
height: 60px;
background: url(http://climg.mukewang.com/58c0f8220001dfce02000060.jpg) no-repeat center center;
float: left;
position: relative;
left: 300px;
top: 50%;
margin-top: -30px;
}
.b-right{
width: 200px;
height: 60px;
background: url(http://climg.mukewang.com/58c0f8780001c74602000060.jpg) no-repeat center center;
float: right;
position: relative;
right: 150px;
top: 50%;
margin-top: -30px;
}
</style>
</head>
<body>
<div class="container">
<div class="left"></div>
<div class="right"></div>
</div>
<div class="footer">
<div class="b-left"></div>
<div class="b-middle"></div>
<div class="b-right"></div>
</div>
</body>
</html>1回答
同学你好, 代码整体效果实现的不错, 这里使用固定的宽度实现就可以了
不过, 同学的代码有些复杂哦,可以简化代码书写量哦, 建议优化:
顶部给图片设置样式的时候, 可以将相同代码提取出来, 然后通过浮动让其在一行显示, 然后margin-left值,实现间距

页脚也是同样的道理

如果帮助到了你, 欢迎采纳!
祝学习愉快~~~~
相似问题