Skip to content Skip to sidebar Skip to footer

Equal Height Divs (two Column)

I tried using JQuery for this, but kind of got lost... so I'm trying to do it with CSS now http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks I basi

Solution 1:

If you are trying to modify the code from the link, all you need to do is modify the css:

#container1 {
       float:left;
       width:100%;
     }

     #col1 {
       float:left;
       width:50%;
       background:red;
     }

     #col2 {
       float:left;
       width:50%;
       background:yellow;
     }   

And I would declare your background color as a hex value and in the container itself, unless of course you want two different color backgrounds for your columns.

Solution 2:

Try putting min-width instead of just width.

Also adding property float:left is a bad practice.

Define a class :

.lfloat {
    float:left;
}

and keep adding it in the div.

Solution 3:

It Can be Easily Done with Some CSS:

<div style="overflow:hidden;"class="fleft">
    <divclass="leftsec content">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.    
    </div><divclass="rightsec content">
        lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.    
    </div>

CSS :

.fleft {
    float: left;
}

.content {
    margin-bottom: -1000px;
    overflow: hidden;
    padding-bottom: 1000px;
}
.leftsec {
    float: left;
    padding-right: 12px;
    width: 208px;
    background:red;
}

.rightsec {
    border-left: 2px solid #000000;
    clear: right;
    left: 0;
    padding-left: 18px;
    background:green;
}  

The Fiddle to the Example: http://jsfiddle.net/m3LsQ/1/

P.S. IE7 has limitations using this code.

Solution 4:

You don`t need JS if you make for modern browser. USE MODERN FEATURES!!! Check my example

.wrapper{
  display: flex;
  flex-direction: row;
}

.col{
  flex: 1; /*make it the same witdh*//*just make it look better*/background: #333;
  color: #fff;
  margin: 05px;
  padding: 5px;
  box-shadow: 003pxrgba(0,0,0,.5);
  /*just make it look better*/
}
<divclass="wrapper"><divclass="col">
    Nunc at facilisis dui. Nam rhoncus blandit bibendum. Ut ligula mi, ornare id pellentesque vel, interdum ut mauris. Proin bibendum nunc non nunc efficitur, sed varius est aliquam. Aliquam semper at sapien a suscipit. Suspendisse potenti. Sed volutpat nulla eu enim ornare, eget vehicula nisi auctor.
  </div><divclass="col">
    test
  </div><divclass="col">
    test
  </div></div>

https://css-tricks.com/snippets/css/a-guide-to-flexbox/ - you can read more about it here

Post a Comment for "Equal Height Divs (two Column)"