Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove the Extra Whitespace Surrounding Iframes?

I am using iframes in my page, and have stumbled across a weird issue. I set the iframe css like so

iframe {     margin: none;     padding: none;     background: blue; /* this is just to make the frames easier to see */     border: none; } 

However, there is still whitespace surrounding the iframe. I tested it in both Chrome and Firefox, and it's the same. I searched around, and I couldn't find anything. This whitespace doesn't show up in the Chrome console, either. Also, I already have the following CSS as well:

html, body {     margin: 0px;     padding: 0px;     border: 0px;     width: 100%;     height: 100%; } 

JSFiddle: here

like image 773
Colin Atkinson Avatar asked Jul 18 '11 15:07

Colin Atkinson


People also ask

How do I align IFrames side by side?

1. Remove width="100%" from the iframes. 2. Change align="right" to align="left" on the second iframe if you want them completely side-by-side.

How do I hide an iframe border?

Remove border from iframe tag in the webpage could be done by using one of the CSS properties of the iframe tag called frameBorder and set its value to “0”. Syntax: frameBorder = "value"; Note: In the frameBorder property the B letter must be in capital otherwise it will not be recognized by the browser.

How do I get an iframe to show full screen?

The ” iframe ” tag defines a rectangular region within the document in which the browser can display a separate document, including scrollbars and borders. An inline frame is used to embed another document within the current HTML document. For the fullscreen Iframe, you have to cover the entire viewport.

Does an iframe have a border around it?

The HTML Iframe frameborder Attribute is used to specify whether or not to display the border around the content of an <Iframe> Element. Attribute Values: 0: It has a Default value. It sets the border on one state.


2 Answers

Having just seen your fiddle your issue is because you are using display:inline-block. This takes whitespace in your html into account. display:inline-block is notorious for being difficult and has dodgy browser support.

Option 1: Try removing the white space in your html can sometimes sort the problem.

Option 2: Using a different display property such as display:block will definitely sort the problem. Live example: http://jsfiddle.net/mM6AB/3/

like image 181
tw16 Avatar answered Sep 23 '22 13:09

tw16


When you are using an inline element, the whitespace might be from the "line" the element is part of (ie. the space below the baseline). The solution then is to add this to its parent element.

line-height: 0; 
like image 25
Jeff Clemens Avatar answered Sep 21 '22 13:09

Jeff Clemens