简体   繁体   中英

How to put !important in all CSS properties using SASS or CSS3?

I'm using the property of BootStrap @include ipad along with SASS to various styles define power to the Ipad.

What I wonder is if there is a way for me to create some variable or something more advanced for all properties within any class (or anything else) are with! Important?

Example:

p {
   white-space: normal;
   height: auto;
    @include ipad {
     width: 280px !important;
     overflow: hidden !important;
     text-overflow: ellipsis !important;
     white-space: nowrap !important;
     }
}

Its place automatically !important in all the properties when the CSS is compiled by SASS?

Thank!

No. Sass does not have a programmatic way of applying the !important flag to the rules for any given selector.

The only thing you can do is increase the specificity of the selector in question.

p {
   white-space: normal;
   height: auto;
   @include ipad {
        body & {
            width: 280px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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