scss Sass Flex Grid

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss Sass Flex Grid相关的知识,希望对你有一定的参考价值。

// Breakpoints map
$breakpoints: (
    xs: $phone,
    sm: $phone--land,
    md: $tablet,
    lg: $desktop,
    xl: $desktop--land,
);

// media query mixin
@mixin break($size) {
    @media (min-width: map-get($breakpoints, $size)) {
        @content;
    }
}

// number of columns variable
$items: 12;

// grid container
.grid {
    display: flex;
    flex-flow: row wrap;
    margin-bottom: 1rem;
}

// grid item
.grid__item {
    padding: 0.5rem;

    &:nth-child(even) {
        background-color: #eee;
    }

    &:nth-child(odd) {
        background-color: #ddd;
    }
}

// loop over the breakpoints
@each $key,
$value in $breakpoints {
    @for $i from 1 through $items {
        .col-#{$key}--#{$i} {
            flex: 0 0 100%;

            @include break($key) {
                flex: 0 0 #{$i / $items * 100%};
            }
        }
    }
}

以上是关于scss Sass Flex Grid的主要内容,如果未能解决你的问题,请参考以下文章

scss Flexbox SASS Mixin:2。flex

scss 简单的sass Grid工作

scss Sass partial:960-12col Grid

scss IE 11 - CSS Grid - SASS mixins

scss Flexbox SASS Mixin:11。flex-basis

scss dinamic vertical align in box css / sass with flex cross browser