如何隐藏iframe,但仍然加载它?等等.播放youtube歌曲.
<iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="display: none;"></iframe>
Run Code Online (Sandbox Code Playgroud)
这将隐藏iframe,但它似乎不会加载iframe.(宋没有上演.)
谢谢
YOU*_*YOU 16
使用可以使用宽度0,高度0和边框0
所以更新的代码将是!
<iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="width:0;height:0;border:0; border:none;"></iframe>
Run Code Online (Sandbox Code Playgroud)
添加:
style="width:0; height:0; border:0; border:none"
它将隐藏它,使媒体在后台播放,它也会崩溃它的空间!
更新小提琴
http://jsfiddle.net/0g51po9t/1/
在我添加绝对定位之前,我仍然遇到iframe占用空间的问题.然后它一起停止占用空间.
<iframe src="/auth/sso/" style="width: 0; height: 0; border: 0; border: none; position: absolute;"></iframe>
使用 CSS 的现有答案对我不起作用。即使display:none
我最终在 iframe 所在的位置得到了一个 4x4 点。我必须做的是以下内容:
<iframe width="0" height="0" frameborder="0" src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1"></iframe>
Run Code Online (Sandbox Code Playgroud)
将可见性设置为隐藏。但是,占用的空间不会崩溃。
<iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="visibility: hidden;"></iframe>
Run Code Online (Sandbox Code Playgroud)