twbs--bootstrap/scss/mixins/_grid-framework.scss

68 lines
1.8 KiB
SCSS
Raw Normal View History

2014-12-02 22:02:35 +00:00
// Framework grid generation
//
// Used only by Bootstrap to generate the correct number of grid classes given
// any value of `$grid-columns`.
%twbs-grid-column {
position: relative;
// Prevent columns from collapsing when empty
min-height: 1px;
// Inner gutter via padding
padding-left: ($grid-gutter-width / 2);
padding-right: ($grid-gutter-width / 2);
2014-12-02 22:02:35 +00:00
}
%twbs-grid-column-float {
float: left
}
2014-12-02 22:02:35 +00:00
@mixin make-grid-columns($columns: $grid-columns) {
@for $i from 1 through $columns {
.col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}, .col-xl-#{$i} {
@extend %twbs-grid-column;
}
2014-12-02 22:02:35 +00:00
}
}
@mixin float-grid-columns($class, $columns: $grid-columns) {
@for $i from 1 through $columns {
.col-#{$class}-#{$i} {
@extend %twbs-grid-column-float;
}
}
}
2014-12-02 22:02:35 +00:00
@mixin calc-grid-column($index, $class, $type, $columns: $grid-columns) {
2014-12-02 22:02:35 +00:00
@if ($type == width) and ($index > 0) {
.col-#{$class}-#{$index} {
width: percentage($index / $columns);
2014-12-02 22:02:35 +00:00
}
}
@if $type == push {
2014-12-02 22:02:35 +00:00
.col-#{$class}-push-#{$index} {
left: if($index > 0, percentage($index / $columns), auto);
2014-12-02 22:02:35 +00:00
}
}
@if $type == pull {
2014-12-02 22:02:35 +00:00
.col-#{$class}-pull-#{$index} {
right: if($index > 0, percentage($index / $columns), auto);
2014-12-02 22:02:35 +00:00
}
}
@if $type == offset {
2014-12-02 22:02:35 +00:00
.col-#{$class}-offset-#{$index} {
margin-left: percentage($index / $columns);
2014-12-02 22:02:35 +00:00
}
}
}
// Create grid for specific class
@mixin make-grid($class, $columns: $grid-columns) {
@include float-grid-columns($class);
2014-12-02 22:02:35 +00:00
@for $i from 0 through $columns {
@include calc-grid-column($i, $class, width, $columns);
@include calc-grid-column($i, $class, push, $columns);
@include calc-grid-column($i, $class, pull, $columns);
@include calc-grid-column($i, $class, offset, $columns);
2014-12-02 22:02:35 +00:00
}
}