首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何消除这些行之间的空隙?

如何消除这些行之间的空隙?
EN

Stack Overflow用户
提问于 2017-01-02 18:14:10
回答 1查看 34关注 0票数 0

我正在做一个练习,在这里我创建了一个由4x3照片组成的网格。我已经通过删除HTML中的间距来消除行内照片之间的空白,但我似乎无法删除行之间的空白。有什么帮助吗?

https://codepen.io/benrichi/pen/MJgOze?editors=1100

HTML

代码语言:javascript
复制
<section id="section_photography">
    <h1>Photography</h1>
    <img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image"><img src="https://placehold.it/350x150" alt="" class="photography_image">
</section>

CSS

代码语言:javascript
复制
#section_photography {
    width: 100vw;
    padding-top: 50px;
    background-color: aqua;
    clear: both;
    position: relative;
}

#section_photography h1 {
    text-align: center;
}

.photography_image {
    width: 25vw;
    margin: none;
    padding: none;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-02 18:29:35

使用垂直对齐:

代码语言:javascript
复制
.photography_image {
    width: 25vw;
    margin: none;
    padding: none;
    vertical-align: bottom;
}

解释:图像是通过内联属性(默认)放置在基线上的,因此它们下面的空间是为字体下降器(g、j、p、q和y)保留的空间。vertical-align: bottom让他们坐在线框的底部。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41431499

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档