微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

XHTML 1.0 Strict中图像下方的不需要的间距

我的目标是在我正在研究的这个页面上使用XHTML 1.0 Strict DOCTYPE,但是我遇到了一些奇怪的设计问题.

我有以下代码

<div><img src="photos/someimage.jpg" alt="Title" /></div>

当我将DOCTYPE设置为1.0 Strict加载页面时,在div中的图像下方添加一点间距.我删除代码中的所有空格/换行符,这似乎是此类问题的常见罪魁祸首.如果我将DOCTYPE更改为1.0 Transitional,则间距消失,页面看起来应该如此.

有人知道在使用1.0 Strict时避免此问题的方法吗?

谢谢你的时间!

解决方法

http://www.schoonzie.com/rogue-padding-below-images

If an image is displayed inline,it leaves a slight space below it. This is because the image is placed on the baseline of the text,and below the baseline there should be some more space for the descender characters like g,j or q.

The offshoot is that in strict mode it’s not possible to make a container fit tightly around the image,unless,of course,you explicitly say img {display: block}.

https://developer.mozilla.org/en/images,_and_mysterious_gaps

The other main choice is leave the image inline and alter the vertical alignment of the image with respect to the line Box. For example,you Could try the following:

06000

原文地址:https://www.jb51.cc/html/231728.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐