Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a newline after a twitter bootstrap element?

I apologize because this seems like such a simple thing.

What's the correct way to insert a newline in a way that the next element is on a newline? It seems like some things automatically do this (such as <p> within `) but I'm seeing behavior where the next element can appear right next to the last element.

HTML:

<ul class="nav nav-tabs span2">     <li><a href="./index.html"><i class="icon-black icon-music"></i></a></li>     <li><a href="./about.html"><i class="icon-black icon-eye-open"></i></a></li>     <li><a href="./team.html"><i class="icon-black icon-user"></i></a></li>     <li><a href="./contact.html"><i class="icon-black icon-envelope"></i></a></li> </ul> <BR /> <!-- It seems dumb to need this!  Is this really how --> <BR /> <!-- to get a newline? --> <BR /> <!-- Well, it's what --> <BR /> <!-- I'm doing now, I suppose... --> <BR />  <div class="well span6">     <h3>I wish this appeared on the next line without having to gratuitously use BR!</h3> </div> 

What is the correct or elegant way to handle newlines after things like ul or div? Am I overlooking a general setup of the code that handles this?

like image 427
Danny Avatar asked Jul 16 '12 08:07

Danny


People also ask

How do I add a line break in bootstrap?

The <br> tag inserts a single line break.

How to force a line break HTML?

To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag.

How to display text in new line in HTML?

To add a line break to your HTML code, you use the <br> tag. The <br> tag does not have an end tag. You can also add additional lines between paragraphs by using the <br> tags. Each <br> tag you enter creates another blank line.

How to enter in HTML next line?

The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.


1 Answers

You're using span6 and span2. Both of these classes are "float:left" meaning, if possible they will always try to sit next to each other. Twitter bootstrap is based on a 12 grid system. So you should generally always get the span**#** to add up to 12.

E.g.: span4 + span4 + span4 OR span6 + span6 OR span4 + span3 + span5.

To force a span down though, without listening to the previous float you can use twitter bootstraps clearfix class. To do this, your code should look like this:

<ul class="nav nav-tabs span2">   <li><a href="./index.html"><i class="icon-black icon-music"></i></a></li>   <li><a href="./about.html"><i class="icon-black icon-eye-open"></i></a></li>   <li><a href="./team.html"><i class="icon-black icon-user"></i></a></li>   <li><a href="./contact.html"><i class="icon-black icon-envelope"></i></a></li> </ul> <!-- Notice this following line --> <div class="clearfix"></div> <div class="well span6">   <h3>I wish this appeared on the next line without having to gratuitously use BR!</h3> </div> 
like image 131
Alexander Wigmore Avatar answered Sep 22 '22 02:09

Alexander Wigmore