Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force div to appear below not next to another?

Tags:

html

css

I would like to place my div below the list, but actually it is placed next to the list.The list is generated dynamically, so it doesn't have a fixed hight. I would like to have the map div on the right, and on the left (next to the map) the list placed on top and the second div below the list(but still on the right to the map)

#map { float:left; width:700px; height:500px; }  #list { float:left; width:200px; background:#eee; list-style:none; padding:0; }  #similar { float:left; width:200px; background:#000; } 
<div id="map">Lorem Ipsum</div>          <ul id="list"><li>Dolor</li></li>Sit</li><li>Amet</li></ul>  <div id ="similar">      this text should be below, not next to ul.  </div>

Any ideas?

like image 732
Vonder Avatar asked Mar 22 '10 14:03

Vonder


People also ask

How do I make a div appear under another div?

You can use the CSS position property in combination with the z-index property to overlay an individual div over another div element. The z-index property determines the stacking order for positioned elements (i.e. elements whose position value is one of absolute , fixed , or relative ).

How do I make div not go to the next line?

css prevent new line div // You should use a <span> element instead, which is inline. // Although it's bad form, you can add style="display: inline;" to a div.

How do I force a div to stay in one line?

You can force the content of the HTML <div> element stay on the same line by using a little CSS. Use the overflow property, as well as the white-space property set to “nowrap”.


1 Answers

use clear:left; or clear:both in your css.

#map { float:left; width:700px; height:500px; }  #list { float:left; width:200px; background:#eee; list-style:none; padding:0; }  #similar { float:left; width:200px; background:#000; clear:both; }    <div id="map"></div>         <ul id="list"></ul> <div id ="similar">  this text should be below, not next to ul. </div> 
like image 169
Matthew Vines Avatar answered Oct 30 '22 15:10

Matthew Vines