HTML - Hide iframe

How to hide iframe but load it? Etc. To play youtube song.

<iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="display: none;"></iframe> 

This will hide the iframe, however it does not seem to load the iframe. (The song does not play.)

thanks

+18
html iframe
source share
6 answers

Usage can use width 0, height 0 and border 0

So, the updated code will be!

 <iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="width:0;height:0;border:0; border:none;"></iframe> 

Added:

style="width:0; height:0; border:0; border:none"

He will hide it, make media for playing in the background, and he will also destroy his space!

Updated script

http://jsfiddle.net/0g51po9t/1/

+15
source share

I still had problems with the iframe taking up space until I added absolute positioning. Then he stopped taking up space together.

<iframe src="/auth/sso/" style="width: 0; height: 0; border: 0; border: none; position: absolute;"></iframe>

+9
source share

Set visibility to hide. However, the space that it occupied will not collapse.

 <iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="visibility: hidden;"></iframe> 
+4
source share

Combining both answers, I use height:0; and visibility:0 , since this works to hide any borders or shadow shadows.

+1
source share

Just set style from "display: none;" .

 <iframe src="your url" style="display: none;"></iframe> 
+1
source share

Existing answers using CSS do not work for me. Even with display:none I got the 4x4 point where the iframe was. I had to do the following:

 <iframe width="0" height="0" frameborder="0" src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1"></iframe> 
0
source share

All Articles