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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:50:00  来源:igfitidea点击:

How to put two iframes side by side

htmlcssiframe

提问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;
}

http://jsfiddle.net/E5WFT/

http://jsfiddle.net/E5WFT/

回答by display-name-is-missing

1.Remove width="100%"from the iframes.

1.width="100%"从 iframe 中删除。

2.Change align="right"to align="left"on the second iframe if you want them completely side-by-side.

2.如果您希望它们完全并排,请更改align="right"align="left"在第二个 iframe 上。

3.Add this CSS:

3.添加此 CSS:

.box { display:inline-block; }

DEMO

演示

回答by Royi Namir

Problems are here :

问题在这里:

enter image description here

在此处输入图片说明

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

为什么是width100%?为什么在div?(这样,他们永远不会并排:-))

Try this :

尝试这个 :

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

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

enter image description here

在此处输入图片说明

回答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%。此外,尽可能不要使用内联样式,因为它们中的许多已经或将被弃用。