How to put two iframes side by side

こ雲淡風輕ζ 提交于 2019-12-21 22:05:30

问题


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.


回答1:


Here you go. use float in div this is basic kindly use search before posting next time.

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:

.box{
    float:left;
    margin-right:20px;
}
.clear{
    clear:both;
}

http://jsfiddle.net/E5WFT/




回答2:


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.

3. Add this CSS:

.box { display:inline-block; }

DEMO




回答3:


Problems are here :

Why width 100% ? and why in div ? ( this way , they will never be side by side :-))

Try this :

http://jsbin.com/hirirazu/3/edit




回答4:


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.



来源:https://stackoverflow.com/questions/23737427/how-to-put-two-iframes-side-by-side

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!