How to put two iframes side by side

2019-04-13 03:25发布

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.

标签: html css iframe
4条回答
唯我独甜
2楼-- · 2019-04-13 03:42

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

查看更多
你好瞎i
3楼-- · 2019-04-13 03:43

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.

查看更多
三岁会撩人
4楼-- · 2019-04-13 03:44

Problems are here :

enter image description 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

enter image description here

查看更多
相关推荐>>
5楼-- · 2019-04-13 03:50

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/

查看更多
登录 后发表回答