简体   繁体   中英

How do I prevent a link tag from adding extra padding below an image?

I have image wrapped in a link. The link adds extra padding in the bottom (Please see the red area in the attached image). How can I remove it? I have tried to set the padding: 0; and margin:0 and also I have tried display:inline-block , but it does not solve it.

在此输入图像描述

HTML:

<a href="#"><img src="http://i50.tinypic.com/2poy3kl.jpg" /></a>​

CSS:

 a{
    background: red;
    padding: 0;
}

JS Fiddle: http://jsfiddle.net/D6Ak8/

Use display: block; for the img tag:

a img {
    display: block;
}

Updated Fiddle: http://jsfiddle.net/D6Ak8/1/

显示块是您的解决方案JS提琴

http://jsfiddle.net/D6Ak8/4/

Add vertical-align:bottom to your image. This way you will keep your inline display.

try

img{border:none;}

...............

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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