user3521680
user3521680

Reputation: 97

How to put two iframes side by side

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.

Upvotes: 6

Views: 66500

Answers (5)

Fritz
Fritz

Reputation: 411

Here is an example of a left and right iframes.

CSS
.menu {
  float:left;
  width:33%;
  height:1250px;
  border:none;
}
.mainContent {
  float:left;
  width:65%;
  height:1250px;
  border:none;
}

index.html
<iframe id="choices" class="menu" name="choices" src="choices.html"></iframe>
<iframe id="main" class="mainContent" name="main" src="main.html"></iframe>

Upvotes: 0

Daniel Euchar
Daniel Euchar

Reputation: 1820

Here is a solution using float and divs

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>
</div>

CSS:

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

http://jsfiddle.net/E5WFT/

Upvotes: 10

Sam Denton
Sam Denton

Reputation: 425

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.

Upvotes: 0

display-name-is-missing
display-name-is-missing

Reputation: 4409

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

Upvotes: 5

Royi Namir
Royi Namir

Reputation: 148744

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

Upvotes: 1

Related Questions