display:inline-block and whitespace

2019-01-20 03:14发布

See this example:

http://jsfiddle.net/EwtaC/1/

The images are styled via display:inline-block. I understand that whitespace somehow has an effect on this.. (for whatever reason) So I removed the whitespace:

from <img src="" /> <img src="" />
to <img src="" /><img src="" />

This removes the spacing to the left and right of the images, but as you can see in the example, the spacing below the images remains..

Is there anything that can be done about that?

Thanks, Wesley

3条回答
Ridiculous、
2楼-- · 2019-01-20 03:46

you can also do

body
{
    line-height:0px;
}
查看更多
Summer. ? 凉城
3楼-- · 2019-01-20 03:51

http://jsfiddle.net/EwtaC/2/

Add:

vertical-align:top;

Images get aligned to baseline by default. Either you display them as block and float them or need to set a proper vertical alignment.

查看更多
Ridiculous、
4楼-- · 2019-01-20 04:02

Instead of inline-block, have you tried just floating the images:

img { float: left; }

Seems to work for me

查看更多
登录 后发表回答