Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create side by side iframe, unlike one line each time. Is there a way. My logic for HTML is as below, but mine is line by line. Please assist mates thanks.

What I have tried:

HTML
<pre><div class="iframe-container">
  <iframe width="650" height="180" style="border: 2px solid #cccccc;" src="https://thingspeak.com/channels/929272/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
<br/>
<div class="iframe-container">
  <iframe width="650" height="180" style="border: 2px solid #cccccc;" src="https://thingspeak.com/channels/929272/charts/2?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
<br/>
<div class="iframe-container">
  <iframe width="650" height="180" style="border: 2px solid #cccccc;" src="https://thingspeak.com/channels/929272/charts/8?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
<div class="wrapper" align="center">
  <div class="btn-group" id="toggle_event_editing">
    <button type="button" class="btn btn-danger locked_active">OFF</button>
    <button type="button" class="btn btn-success unlocked_inactive">ON</button>
  </div>
  <div class="alert alert-info" id="switch_status">Switched off.</div>
</div>
<br/>
Posted
Updated 9-Jan-20 4:16am
Comments
ZurdoDev 9-Jan-20 7:51am    
If you google the question there are lots of examples online.
ZurdoDev 9-Jan-20 7:51am    
And you seem to have already asked this question.

Quote:
I want to create side by side iframe,
If you want them to be shown side-by-side then use the Bootstrap's grid system. You can create a single row, then 6 by 6 columns would contain the iframes side-by-side.

Grid system · Bootstrap[^]

Kind of like this:
<div class="container">
  <div class="row">
    <div class="col">
      <p>First iframe here.</p>
    </div>
    <div class="col">
      <p>Second iframe here.</p>
    </div>
  </div>
</div>
Try a quick fiddle here, Bootstrap grid - JSFiddle[^]
 
Share this answer
 
The reason you are seeing this is that DIV is a block level element, and it's default behavior is to stack vertically as you have found.
The ways to alter this behavior are for that DIV to have styles placed onto it that alter the defaults OR to nest it within an inline element.

There are multiple ways you can do this; you could use a library such as Bootstrap which will give you predefined element style or you could simply add in a few lines of CSS to do the same thing.

I am not going to go into Bootstrap as it is well documented.

To do this via CSS, you can simply change Display parameter of the DIV in question to inline or inline-block/
The following code added into the head of your document will alter all DIVs that have the iframe-container class, which will allow your iframes to be side-by-side (if the page width allows it)
HTML
<style type="text/css">
  .iframe-container { display: inline-block; }
</style>
Adding in a second line of CSS will allow you to remove some of the attributes from the iframes (height, width, style)
HTML
<style type="text/css">
  .iframe-container {display: inline;}
  .iframe-container iframe {height: 180px; width: 600px; border: 2px solid #ccc;}
</style>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900