Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting a div on a new line (problem caused by floating <ul> elements)

So I have a 3 unordered lists like so:

  <ul class="menu"> <li class="heading">Title (Click To Download)</li> <li><a title="Download sample.mp3" href="http://example.com/sample.mp3">Sample Song</a></li> </ul> 

With the following css style:

/* SITE MAP MENUS */  ul.menu {      float: left;     margin: 0 10px 0 10px;     display: block;     font-size: 13px;     line-height: 24px;     color: #898989; }   ul.menu li {}  .menuText {  } li.heading {     color: #493f0b;     font-weight: bold;     border-bottom: 1px solid #d7d7d7; } 

However when I put a new div:

<div class="pleasedontfloat">The paganation would go here..</div> 

Instead of going below the lists it goes next to them. How would I fix this? (the class pleasedontfloat has no rules applied to it)

like image 976
Christopher Tarquini Avatar asked Dec 08 '09 20:12

Christopher Tarquini


People also ask

How do I keep my div in a new line?

Set size and make inline Because they're block elements, when reducing the size of Div one to make room for the other div, you're left with space next to Div one and Div two below Div one. To move the div up to the next line both div's need to have the inline-block display setting as shown below.

Does div cause a line break?

By default <DIV> does cause a line break. You probably want to use a <SPAN> . Show activity on this post. You could make them float, but for menu items, it is far more common to use lists to create these.

Should I use div or UL?

They're just tags. There's zero difference whatsoever between them DOM-wise; the only difference is in the rendering (CSS, which you can customize either way) and the meaning (semantics). If you have a list of things, use a <ul> .

How do you keep div elements in the same line?

To get all elements to appear on one line the easiest way is to: Set white-space property to nowrap on a parent element; Have display: inline-block set on all child elements.


1 Answers

.pleasedontfloat {      clear:both; }  
like image 155
jball Avatar answered Sep 20 '22 15:09

jball