开发者

hide a space inside divs?

I have a div with 2 images side by side. Theres a space seperating the tags. Thus a space between the two images. Is the开发者_JS百科re a way i can use css to hide the space (or text) inside of that div?


You can style the <img> with display: block; float: left;. This should remove the space, since images are inline elements by default.

<img src="image1.png" style="display: block; float: left;"> 
<img src="image2.png" style="display: block; float: left;"> 


Just remove the space between the tags in the html...

An image is an inline element, which means it takes into account any text surrounding it. That includes spaces. Making them display:block elements would solve it if you specified their widths.

You could make them display:table, but that is a nasty hack that should be avoided. I don't even think they would be side by side then, but i could be wrong.


Or you can put it in a <span/> and hide that whenever you hide the div. Or put the image in a div with padding. Or put margin on the image instead of a space. Lots of ways to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜