Skip to content

Instantly share code, notes, and snippets.

@adamstac
Created August 9, 2011 04:54
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamstac/1133433 to your computer and use it in GitHub Desktop.
Save adamstac/1133433 to your computer and use it in GitHub Desktop.
Faux equal height columns hack using pure CSS / Sass (with jQuery fallback for IE 6 & 7)
.two-columns {
overflow: hidden;
*zoom: 1;
position: relative;
}
.two-columns .column-one, .two-columns .column-two {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
padding: 15px;
}
.two-columns .column-one:before, .two-columns .column-two:before {
position: absolute;
top: 0;
content: "";
height: 100%;
z-index: -1;
}
.two-columns .column-one {
float: left;
width: 590px;
}
.two-columns .column-one:before {
left: 0;
background: white;
width: 590px;
}
.two-columns .column-two {
float: left;
width: 370px;
}
.two-columns .column-two:before {
right: 0;
background: #fafafa;
width: 370px;
}
@import "compass"
.two-columns
+clearfix
position: relative
.column-one, .column-two
+box-sizing(border-box)
padding: 15px
&:before
position: absolute
top: 0
content: ""
height: 100%
z-index: -1
.column-one
$width: 590px
float: left
width: $width
&:before
left: 0
background: #fff
width: $width
.column-two
$width: 370px
float: left
width: $width
&:before
right: 0
background: $lightest-grey
width: $width
$(document).ready(function() {
$('.column-one, .column-two').before('');
});
@adamstac
Copy link
Author

adamstac commented Aug 9, 2011

This could easily get extracted to a better reusable mixin with conditionals and variables for easier usage too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment