Skip to content

Instantly share code, notes, and snippets.

@barryvdh
Created March 13, 2012 15:40
Show Gist options
  • Save barryvdh/2029466 to your computer and use it in GitHub Desktop.
Save barryvdh/2029466 to your computer and use it in GitHub Desktop.
Old Bootstrap grid code (mixin.less) for compatibilty with phpLess
// The Grid
#grid {
.core (@gridColumnWidth: @gridColumnWidth , @gridGutterWidth: @gridGutterWidth) {
.span (@columns) {
width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
}
.offset (@columns) {
margin-left: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1)) + (@gridGutterWidth * 2);
}
.row {
margin-left: @gridGutterWidth * -1;
.clearfix();
}
[class*="span"] {
float: left;
margin-left: @gridGutterWidth;
}
// Set the container width, and reset it for fixed navbars
.container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container { .span(12); }
.span1 { .span(1); }
.span2 { .span(2); }
.span3 { .span(3); }
.span4 { .span(4); }
.span5 { .span(5); }
.span6 { .span(6); }
.span7 { .span(7); }
.span8 { .span(8); }
.span9 { .span(9); }
.span10 { .span(10); }
.span11 { .span(11); }
.span12 { .span(12); }
.offset1 { .offset(1); }
.offset2 { .offset(2); }
.offset3 { .offset(3); }
.offset4 { .offset(4); }
.offset5 { .offset(5); }
.offset6 { .offset(6); }
.offset7 { .offset(7); }
.offset8 { .offset(8); }
.offset9 { .offset(9); }
.offset10 { .offset(10); }
.offset11 { .offset(11); }
.offset12 { .offset(12); }
}
.fluid (@fluidGridColumnWidth, @fluidGridGutterWidth) {
.span (@columns) {
width: 1% * (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1));
}
.row-fluid {
width: 100%;
.clearfix();
> [class*="span"] {
float: left;
margin-left: @fluidGridGutterWidth;
}
> [class*="span"]:first-child {
margin-left: 0;
}
> .span1 { .span(1); }
> .span2 { .span(2); }
> .span3 { .span(3); }
> .span4 { .span(4); }
> .span5 { .span(5); }
> .span6 { .span(6); }
> .span7 { .span(7); }
> .span8 { .span(8); }
> .span9 { .span(9); }
> .span10 { .span(10); }
> .span11 { .span(11); }
> .span12 { .span(12); }
}
}
.input(@gridColumnWidth, @gridGutterWidth) {
.span(@columns) {
width: ((@gridColumnWidth) * @columns) + (@gridGutterWidth * (@columns - 1)) - 10;
}
input,
textarea,
.uneditable-input {
margin-left: 0; // override margin-left from core grid system
> .span1 { .span(1); }
> .span2 { .span(2); }
> .span3 { .span(3); }
> .span4 { .span(4); }
> .span5 { .span(5); }
> .span6 { .span(6); }
> .span7 { .span(7); }
> .span8 { .span(8); }
> .span9 { .span(9); }
> .span10 { .span(10); }
> .span11 { .span(11); }
> .span12 { .span(12); }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment