0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00
Bootstrap/scss/mixins/_grid-framework.scss

72 lines
2.0 KiB
SCSS
Raw Normal View History

2014-12-02 23:02:35 +01:00
// Framework grid generation
//
// Used only by Bootstrap to generate the correct number of grid classes given
// any value of `$grid-columns`.
// Common properties for all breakpoints
@mixin make-grid-columns($columns: $grid-columns, $breakpoints: $grid-breakpoints) {
%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 23:02:35 +01:00
}
@for $i from 1 through $columns {
@each $breakpoint in $breakpoints {
.col-#{$breakpoint}-#{$i} {
@extend %grid-column;
}
}
}
}
2014-12-02 23:02:35 +01:00
// Breakpoint-specific properties
@mixin make-grid($breakpoint, $columns: $grid-columns) {
// Work around cross-media @extend (https://github.com/sass/sass/issues/1050)
%grid-column-float-#{$breakpoint} {
float: left;
2014-12-02 23:02:35 +01:00
}
@for $i from 1 through $columns {
.col-#{$breakpoint}-#{$i} {
@extend %grid-column-float-#{$breakpoint};
@include grid-column-width($i, $columns);
2014-12-02 23:02:35 +01:00
}
}
@each $modifier in (pull, push, offset) {
@for $i from 0 through $columns {
.col-#{$breakpoint}-#{$modifier}-#{$i} {
@include grid-column-modifier($modifier, $i, $columns)
}
2014-12-02 23:02:35 +01:00
}
}
}
@mixin grid-column-width($index, $columns) {
width: percentage($index / $columns);
}
@mixin grid-column-push($index, $columns) {
left: if($index > 0, percentage($index / $columns), auto);
}
@mixin grid-column-pull($index, $columns) {
right: if($index > 0, percentage($index / $columns), auto);
}
@mixin grid-column-offset($index, $columns) {
margin-left: percentage($index / $columns);
}
// Work around the lack of dynamic mixin @include support (https://github.com/sass/sass/issues/626)
@mixin grid-column-modifier($type, $index, $columns) {
@if $type == push {
@include grid-column-push($index, $columns);
} @else if $type == pull {
@include grid-column-pull($index, $columns);
} @else if $type == offset {
@include grid-column-offset($index, $columns);
2014-12-02 23:02:35 +01:00
}
}