Html 如何并排放置两个iframe
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23737427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to put two iframes side by side
提问by user3521680
I have tried several codes, like this one:
我尝试了几种代码,例如:
<div class="box"><iframe src="https://embed.spotify.com/?uri=spotify:user:1290230929:playlist:6nTIVNGZfnZ4urUiwHIgpT"
frameborder="0"
scrolling="no"
width="100%"
height="512"
align="left"> </iframe> </div>
<div class="box"><iframe src="https://embed.spotify.com/?uri=spotify:user:1285279066:playlist:56KI83cMiMTOocIdXq2R5j"
frameborder="0"
scrolling="no"
width="100%"
height="512"
align="right">
</iframe>
And it does not work side by side, if someone can fix this for me, thank you.
它不能并行工作,如果有人可以为我解决这个问题,谢谢。
回答by Daniel Euchar
Here you go. use float in div this is basic kindly use search before posting next time.
干得好。在 div 中使用 float 这是基本的,请在下次发布之前使用搜索。
HTML:
HTML:
<div class="box"><iframe src="https://embed.spotify.com/?uri=spotify:user:1290230929:playlist:6nTIVNGZfnZ4urUiwHIgpT" frameborder="0" scrolling="no" width="100%" height="512" align="left"> </iframe> </div>
<div class="box"> <iframe src="https://embed.spotify.com/?uri=spotify:user:1285279066:playlist:56KI83cMiMTOocIdXq2R5j" frameborder="0" scrolling="no" width="100%" height="512" align="right">
</iframe>
CSS:
CSS:
.box{
float:left;
margin-right:20px;
}
.clear{
clear:both;
}
回答by display-name-is-missing
回答by Royi Namir
Problems are here :
问题在这里:
Why width
100% ? and why in div
? ( this way , they will never be side by side :-))
为什么是width
100%?为什么在div
?(这样,他们永远不会并排:-))
Try this :
尝试这个 :
http://jsbin.com/hirirazu/3/edit
http://jsbin.com/hirirazu/3/edit
回答by Sam Denton
It can't work where width is 100%, as that states that the width of the iframe is 100% of the body. Also, don't use inline styles where possible as many of them are or will be deprecated.
它不能在宽度为 100% 的情况下工作,因为这表明 iframe 的宽度是正文的 100%。此外,尽可能不要使用内联样式,因为它们中的许多已经或将被弃用。