Extend only first level on Sass

前端 未结 1 1388
天命终不由人
天命终不由人 2021-01-28 12:00

I have few lines of Sass:

.content{
   width: 960px;
   padding: 15px 0;
   margin: auto;
   background: inherit;

   p{
       text-align: justify;
       paddi         


        
1条回答
  •  孤城傲影
    2021-01-28 12:30

    No. If you extend a selector, you extend all of the selectors that have the same name (including .foo .content). Your best option is to have multiple selectors to extend from:

    %foo {
       width: 960px;
       padding: 15px 0;
       margin: auto;
       background: inherit;
    }
    .content {
       @extend %foo;
       p {
           text-align: justify;
           padding: 10px;
       }
    }
    
    .header {
        @extend %foo;
    }
    

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