简体   繁体   English

Bootstrap SASS结果

[英]Bootstrap SASS result

I use Bootstrap 3.3.5 with SASS. 我将Bootstrap 3.3.5与SASS一起使用。 But the CSS final's file is strange. 但是CSS final的文件很奇怪。

I write that : 我写:

section.strat-01 {
    @include make-row();

    .strat-01-img {
        @include make-xs-column(12);
        @include make-sm-column-offset(1);
        @include make-sm-column(4);
        @include make-sm-column-pull(6);    
    }

    .strat-01-txt {
        @include make-xs-column(12);
        @include make-sm-column(6);
        @include make-sm-column-push(5);
    }
}

And I have that, double properties : 而且我有双重属性:

section.strat-01 .strat-01-img {
            position: relative;
            float: left;
            width: 100%;
            min-height: 1px;
            padding-left: 15px;
            padding-right: 15px;
            position: relative;
            min-height: 1px;
            padding-left: 15px;
            padding-right: 15px; 
}

What's wrong ? 怎么了 ? Why the double properties are not combined ? 为什么不合并double属性?

来自多个mixin的重复属性永远不会合并在一起...

What I think you want to do here is just split this up into multiple media queries as mentioned in the comments. 我认为您想要在此处执行的操作只是将其拆分为多个媒体查询,如评论中所述。

The reason your output CSS seems 'dumb' is because SASS is only a pre compiler, whatever you put into it comes out and thus using multiple mixins in the same selector are simply giving you back all their values. 您的输出CSS似乎是“哑巴”的原因是因为SASS只是一个预编译器,无论您输入什么,它都会出来,因此在同一个选择器中使用多个mixins只会将所有值都还给您。

The reason CSS doesn't filter this is because it will simply overwrite or extend rules / selectors defined earlier which is how CSS works (Cascading Style Sheets) CSS无法过滤的原因是,它只会覆盖或扩展先前定义的规则/选择器,这就是CSS的工作方式(级联样式表)

Either way you don't have a lot of work to do to make it work, all you'll want for the correct CSS to be applied at the correct resolution is to split it in media queries eg 无论哪种方式,您都不需要做很多工作来使它工作,要以正确的分辨率应用正确的CSS,您要做的就是将其拆分到媒体查询中,例如

$my-sm-res: 768px //for instance
$my-xs-res: 480px //for instance

@media (max-width: $my-sm-res)
    .section.strat-01
        .strat-01-img
            @include make-sm-column-offset(...)
            @include make-sm-column(...)
            @include make-sm-column-pull(...)

@media (max-width: $my-xs-res)
    .section.strat-01
        .strat-01-img
            @include make-xs-column-offset(...)
            @include make-xs-column(...)
            @include make-xs-column-pull(...)

This example here is what will give you the xs styling when your screen has a resulution of 480px or less and will give you the md styling for when your screen has a resolution of 768px or less. 这里这个例子是什么会给你XS造型时,你的屏幕具有480像素或更低的resulution,并给你当你的屏幕有768px或更小,分辨率为MD的造型。

Hope it helps, GL! 希望对您有所帮助,GL!

EDIT 编辑

I'm using the SASS format here which is technically not valid CSS (nor is SCSS really but if you pull out the sassy bits you'll be left with valid CSS instead of SASS that you still have to change.) 我在这里使用的SASS格式在技术上不是有效的CSS(SCSS也不是,但是如果您拉开了时髦的位,您将获得有效的 CSS而不是必须更改的SASS。)

For the example to work in your situation all you'd need to do is add the missing {} pairs and add ; 为了使示例适合您的情况,您要做的就是添加丢失的{}对并添加; semicolons at the end of each prop: val pair. 每个prop: val末尾的分号prop: val对。

More on SASS vs SCSS (for those interested) 有关SASS与SCSS的更多信息 (对于那些感兴趣的人)

Some basics on CSS (MDN) CSS(MDN)的一些基础知识

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM