请老师检查。谢谢。
来源:4-11 自由编程
慕斯卡2474635
2021-06-06 22:42:38
/* Gallery区域 */
.gallery .short h2 {
font-size: 32px;
text-align: center;
}
.gallery .short p {
text-align: center;
color: gray;
font-size: 14px;
}
.gallery .picture {
padding: 21.5px 20px;
width: 1160px;
height: 610px;
margin: 0 auto;
}
.gallery .picture dl {
float: left;
margin-right: 40px;
margin-bottom: 30px;
}
.gallery .picture dl.none {
margin-right: 0;
}
.gallery .picture dl img {
width: 360px;
height: 240px;
display: block;
}
.gallery .picture dl dd {
height: 50px;
width: 340px;
background-color: black;
color: white;
line-height: 50px;
padding-left: 20px;
}
/* Footer区域 */
footer {
margin-top: 10px;
width: 100%;
height: 80px;
background-color: #07cbc9;
text-align: center;
line-height: 80px;
}
<!-- Gallery区域 -->
<div class="gallery">
<div class="short">
<h2>GALLERY</h2>
<div class="dividing-line"></div>
<p> Lorem Ipsum is simply dummy text of the printing and typesetting <br> industry. Lorem Ipsum has been the industry's standard dummy <br> text ever since the 1500s.</p>
</div>
<div class="picture">
<dl>
<dt>
<img src="images/03-01.jpg" alt="">
</dt>
<dd>Science Lab</dd>
</dl>
<dl>
<dt>
<img src="images/03-02.jpg" alt="">
</dt>
<dd>Indoor Stadium</dd>
</dl>
<dl class="none">
<dt>
<img src="images/03-03.jpg" alt="">
</dt>
<dd>Transportation</dd>
</dl>
<dl>
<dt>
<img src="images/03-04.jpg" alt="">
</dt>
<dd>Kids Room</dd>
</dl>
<dl>
<dt>
<img src="images/03-05.jpg" alt="">
</dt>
<dd>Meditation aclasses</dd>
</dl>
<dl class="none">
<dt>
<img src="images/03-06.jpg" alt="">
</dt>
<dd>Kids Play Ground</dd>
</dl>
</div>
</div>
<!-- Footer区域 -->
<footer>
<div>©2016 imooc.com 京ICP备13046642号</div>
</footer>
为什么footer如果不设置 margin-top: 10px;
文字就不能居中显示
1回答
同学你好,代码布局以及实现效果很棒!
针对提问回复:
文字不能居中显示是因为上面元素超出了,覆盖footer一部分

是picture元素设置高度610px小了,元素超出了。建议去掉固定高度,用overflow属性消除浮动的影响:

祝学习愉快!
相似问题