图片之间的缝隙该怎么去除?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>经典行布局2-7编程练习</title>
<style type="text/css">
/* 清楚默认样式 */
*{margin:0;padding:0;}
a{
text-decoration: none;
font-size:25px;
color:cornsilk;
}
/* 给页头添加样式 */
.header{
width:100%;
height:100px;
background:black;
line-height:100px;
position:fixed;
top:0;
}
.nav{
width:600px;
height:50px;
float:right;
position:absolute;
right:0;
top:0;
}
.nav a{margin-right:40px;}
/* 设置网页主体内容的CSS样式 */
.content{
padding-top:100px;
padding-bottom:100px;
}
.content img{margin-top:0;}
/* 设置页尾的CSS样式 */
.footer{
width:100%;
height:100px;
background:black;
line-height:100px;
text-align:center;
position:fixed;
bottom:0;
}
.footer a{margin:40px;}
</style>
</head>
<body>
<!-- 页头导航区 -->
<div class="header">
<div class="logo">
<a href="#">
<img src="http://img1.sycdn.imooc.com/climg//58c0d2d900016ce303000100.png"/>
</a>
</div>
<div class="nav">
<a href="#">课程</a>
<a href="#">职业路径</a>
<a href="#">实战</a>
<a href="#">猿问</a>
<a href="#">手记</a>
</div>
</div>
<!-- 网页主要内容区 -->
<div class="content">
<img src="http://img1.sycdn.imooc.com/climg//58c0eda50001e12416000480.jpg"/>
<img src="http://img1.sycdn.imooc.com/climg//58c0edb80001c9f216000480.jpg"/>
<img src="http://img1.sycdn.imooc.com/climg//58c0edc9000100d516000480.jpg"/>
</div>
<!-- 页尾 -->
<div class="footer">
<a href="#">网站首页</a>
<a href="#">企业合作</a>
<a href="#">人才招聘</a>
<a href="#">联系我们</a>
<a href="#">常见问题</a>
<a href="#">友情链接</a>
</div>
</body>
</html>老师,麻烦帮我看一下代码有什么需要改的地方
还有图片之间的缝隙应该怎么去除?
0
收起
正在回答
1回答
你好同学,图片默认的缝隙是行内标签img换行导致的,属于一个特殊现象 。设置成块元素即可解决。另外,图片建议设置成宽度100%,这样在任何屏幕的电脑上都能相对浏览器100%显示。如下优化:

同样,logo的a标签和img也建议设置成块元素更好,导航的a因为要在一行显示,所以不设置没有关系。

祝学习愉快 ,望采纳。
相似问题
登录后可查看更多问答,登录/注册
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星