Skip to content

Instantly share code, notes, and snippets.

@gearsdigital
Created September 17, 2015 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gearsdigital/29b671d8f4a5ae97d003 to your computer and use it in GitHub Desktop.
Save gearsdigital/29b671d8f4a5ae97d003 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
// Grid settings
$grid-gutter-width: 8px !default;
$grid-columns: 12 !default;
$breakpoints: (xs: 320, sm: 768, md: 1024, lg: 1440);
%clearfix {
&:before,
&:after {
content: ' ';
display: table;
}
&:after {
clear: both;
}
}
%container-fluid {
@extend %clearfix;
padding-left: ($grid-gutter-width / 2);
padding-right: ($grid-gutter-width / 2);
margin: 0 auto;
max-width: map-get($breakpoints, 'lg');
@media (min-width: map-get($breakpoints, 'xs')) {
padding: 0 4px;
}
@media (min-width: map-get($breakpoints, 'sm')) {
padding: 0 10px;
}
}
%row {
@extend %clearfix;
margin-left: ($grid-gutter-width / -2);
margin-right: ($grid-gutter-width / -2);
}
@mixin make-row($gutter: $grid-gutter-width) {
@extend %clearfix;
margin-left: ($gutter / -2);
margin-right: ($gutter / -2);
}
@mixin make-grid-columns($i: 1, $list: "%col-xs-#{$i}, %col-sm-#{$i}, %col-md-#{$i}, %col-lg-#{$i}") {
@for $i from (1 + 1) through $grid-columns {
$list: "#{$list}, %col-xs-#{$i}, %col-sm-#{$i}, %col-md-#{$i}, %col-lg-#{$i}";
}
#{$list} {
position: relative;
min-height: 1px;
padding-left: ($grid-gutter-width / 2);
padding-right: ($grid-gutter-width / 2);
}
}
@mixin float-grid-columns($class, $i: 1, $list: "%col-#{$class}-#{$i}") {
@for $i from (1 + 1) through $grid-columns {
$list: "#{$list}, %col-#{$class}-#{$i}";
}
#{$list} {
float: left;
}
}
@mixin calc-grid-column($index, $class, $type) {
@if ($type == width) and ($index > 0) {
%col-#{$class}-#{$index} {
width: percentage(($index / $grid-columns));
}
}
@if ($type == push) and ($index > 0) {
%col-#{$class}-push-#{$index} {
left: percentage(($index / $grid-columns));
}
}
@if ($type == push) and ($index == 0) {
%col-#{$class}-push-0 {
left: auto;
}
}
@if ($type == pull) and ($index > 0) {
%col-#{$class}-pull-#{$index} {
right: percentage(($index / $grid-columns));
}
}
@if ($type == pull) and ($index == 0) {
%col-#{$class}-pull-0 {
right: auto;
}
}
@if ($type == offset) {
%col-#{$class}-offset-#{$index} {
margin-left: percentage(($index / $grid-columns));
}
}
}
@mixin loop-grid-columns($columns, $class, $type) {
@for $i from 0 through $columns {
@include calc-grid-column($i, $class, $type);
}
}
@mixin make-grid($class) {
@include float-grid-columns($class);
@include loop-grid-columns($grid-columns, $class, width);
@include loop-grid-columns($grid-columns, $class, pull);
@include loop-grid-columns($grid-columns, $class, push);
@include loop-grid-columns($grid-columns, $class, offset);
}
// genrate grid
@include make-grid-columns;
@each $key, $value in $breakpoints {
@media (min-width: $value+px) {
@include make-grid($key);
}
}
// css
.cart {
@extend %col-xs-1;
@extend %col-md-3;
@extend %col-sm-3;
}
.cart, .cart, .cart {
position: relative;
min-height: 1px;
padding-left: 4px;
padding-right: 4px;
}
@media (min-width: 320px) {
.cart {
float: left;
}
.cart {
width: 8.33333%;
}
}
@media (min-width: 768px) {
.cart {
float: left;
}
.cart {
width: 25%;
}
}
@media (min-width: 1024px) {
.cart {
float: left;
}
.cart {
width: 25%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment