SASS/SCSS: Refer to property without using an intermediate variable

后端 未结 2 1445
野性不改
野性不改 2020-12-10 13:50

Is it possible to refer to a property previously defined in a selector without introducing an intermediate variable?

I\'d like to say something like:



        
相关标签:
2条回答
  • 2020-12-10 14:10

    If its an option to use an other preprocessor then scss, I really recommend using Stylus. There is a feature called Property lookup which is exactly what you want.

    0 讨论(0)
  • 2020-12-10 14:13

    No, you can't, and it would be great.

    I haven't tested, but as far as I know the only css pre-processor that can do that is stylus. Look at the variable section in its documentation, where it says Property Lookup. It works that way:

    .foo {
      padding: 15px;
      width: 300px - @padding * 2;
    }
    

    But no, in Sass you can't, as far as I'm concerned.

    0 讨论(0)
提交回复
热议问题