Unwanted spacing below images in XHTML 1.0 Strict

后端 未结 2 1905
盖世英雄少女心
盖世英雄少女心 2020-12-18 10:22

My goal is to use the XHTML 1.0 Strict DOCTYPE for this page I\'m working on, but I\'m running into some weird design issues..

I have the below code:



        
相关标签:
2条回答
  • 2020-12-18 10:35

    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,_tables,_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:

    div img {vertical-align: bottom;}
    
    0 讨论(0)
  • 2020-12-18 10:47

    Try this

    <div style="font-size: 0px;"><img src="photos/someimage.jpg" alt="Title" /></div>
    
    0 讨论(0)
提交回复
热议问题