CSS - How to remove whitespace between anchored images

Deadly 提交于 2019-12-21 19:17:26

问题


I have two anchored images on top of each other, separated with a line break. I want the images to sit directly on top of each other, but in Firefox there is a gap between the images. It works in IE7. The only way I have been able to fix this is by changing the line-height (which I don't want to do).

<a href="image.jpg">
    <img height="75" width="75" src="image.jpg" />
</a>
<br/>
<a href="image2.jpg">
    <img height="75" width="75" src="image2.jpg" />
</a>

回答1:


Placing the CSS property vertical-align to bottom on the top image will remove the gap in Firefox.




回答2:


Perhaps setting the images to display:block would work. As an image is by default inline with the text, it leaves space at the bottom for descendenders (such as j,g,and y), even though an image will never have any. Many browsers account for this, but doing so is non-standard. Setting them to block should remove this annoyance in all browsers.



来源:https://stackoverflow.com/questions/1111783/css-how-to-remove-whitespace-between-anchored-images

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!