Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of this CSS in Twitter Bootstrap?

<div style="float:left;">
    column 1
</div>
<div style="float:left;">
    column 2
</div>
<div style="clear:both;"></div>

I'm used to writing clear:both. But I heard in Twitter Bootstrap there is something called "clearfix"? On which element should/would I apply "clearfix"?

like image 926
user847495 Avatar asked Dec 07 '22 17:12

user847495


2 Answers

You probably only have to do:

<div class="container">
   <div class="row">
      <div class="span6">column 1</div>
      <div class="span6">column 2</div>
   </div>
</div>

clearfix should not be necessary.

like image 132
artlung Avatar answered Dec 25 '22 23:12

artlung


using css you can simple use the after psudeo

.class1:after, .class2:after //append as many as you like
{
 clear:both;
 *zoom:1;
 height:0;
 visibility: hidden;
 display:block;
}

alternative(providing children are not using the position selector)
(parent-elemts){overflow:hidden;}//bit of a quick fix!

keep unwanted markup out of your html file

Edit: sorry! for some reason the add comment button or upvote button is not working for me tonight.

To append my answer to answer your other question:

twitter bootstrap you say uses a .clearfix class, which is similar to the css I provided below, however their method needs to be added to the element, ie: "element class="clearfix" OR similar, where as css pseduo's we dont need to add this extra bit of code to our document. Take note however, not all browsers support css pseduo's.

like image 40
Philip Avatar answered Dec 25 '22 22:12

Philip