HTML: Strange space between iframe elements?

前端 未结 4 1964
谎友^
谎友^ 2020-12-29 06:50

Question:

Consider the following HTML:






相关标签:
4条回答
  • 2020-12-29 07:34

    Specify the seamless attribute, which is introduced in HTML 5. http://www.quackit.com/html_5/tags/html_iframe_tag.cfm

    0 讨论(0)
  • 2020-12-29 07:35

    Just a quick note (Because I was having this problem on IE)...

    Trying setting:

    font-size: 0px;
    

    This worked (I believe because, as someone suggested, the iframes are places on the text baseline).

    Goodluck y'all!

    0 讨论(0)
  • 2020-12-29 07:36

    An iframe in standards mode is display: inline by default. That means they will be placed on the text baseline, ie. where the bottom of an 'a' ends, not where the bottom of a 'y' does. The gap you're seeing is the space for descenders in the line of text. This should remove it:

    iframe { display: block; }
    
    0 讨论(0)
  • 2020-12-29 07:55

    Just add

    <style>iframe { vertical-align:bottom; } </style>
    

    or

    <style>iframe { display:block; } </style>
    

    <!DOCTYPE html> puts the browser into standards mode, where inline elements are placed on the baseline of the containing block and a space for the character descenders is always allocated in the line box. In other modes, that space is only created when there are printable characters on the same line as the iframes which isn't the case here. Moving the iframe off the baseline by either of the methods above allows the space for the descenders to be placed within the height of the iframe.

    0 讨论(0)
提交回复
热议问题