简体   繁体   English

在div内的图片下添加额外填充?

[英]Extra Padding under image inside div?

For some reason, it seems like there is extra padding on the bottom of my div that holds an image inside it. 出于某种原因,我的div底部似乎有多余的填充物,用于在其中保留图像。

Here is the JSFiddle: http://jsfiddle.net/KSs7V/ 这是JSFiddle: http : //jsfiddle.net/KSs7V/

Any idea on how that got there/how to fix it? 关于如何到达那里/如何解决它的任何想法?

CSS: CSS:

.artist-box {
    width: 100%;
    text-align: center;
    position: relative;
    display: inline-block;
}

.artist-pic {
    height: 245px;
    margin: 0;
    /*box-shadow: 0 0 10px black;*/
}
#artist-wrap {
    max-width: 1800px;
    margin-top: 5px;
}

.indArtistBox {
    display: inline-block;
    margin-right: 10px;
    position: relative;
    border: 1px solid #000;
}

Just add vertical-align:top or display:block to your image rules: 只需在图像规则中添加vertical-align:topdisplay:block即可:

.artist-pic {
    height: 245px;
    margin: 0;
    vertical-align:top;
    /*box-shadow: 0 0 10px black;*/
}

jsFiddle example jsFiddle示例

An alternate option is to add font-size:0 on the image container div: 另一种选择是在图像容器div上添加font-size:0

.indArtistBox {
    display: inline-block;
    margin-right: 10px;
    position: relative;
    border: 1px solid #000;
    font-size:0;
}

jsFiddle example jsFiddle示例

The gap is due to the space reserved for descender elements (eg 'j', 'g', 'y') as images are inline elements. 间隙是由于图像是嵌入式元素而为下级元素(例如'j','g','y')保留的空间所致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM