skip to Main Content

I don’t want to write a second-time label selector. How can I merge both CSS?

Don’t apply padding-right for the .mat-checkbox selector.

label, .mat-checkbox .mat-checkbox-layout .mat-checkbox-label {
    color: #5b5b5b !important;
    font-weight: 600 !important;
}

label {
    padding-right: 1em;
}

I have tried but not working. Anyone can provide solution?

label, .mat-checkbox .mat-checkbox-layout .mat-checkbox-label {
    color: #5b5b5b !important;
    font-weight: 600 !important;
    
    & {
        padding-right: 1em;
    }
}

2

Answers


  1. If .mat-checkbox .mat-checkbox-layout .mat-checkbox-label is also a <label>, you could try something like this.

    label {
        color: #5b5b5b !important;
        font-weight: 600 !important;
    
        &:not(.mat-checkbox .mat-checkbox-layout .mat-checkbox-label) {
            padding-right: 1em;
        }
    }
    
    
    Login or Signup to reply.
  2. This is not possible.

    Your first rule applies to "all" elements, and its child rules can not apply to a single parent element.

    You implemented it the best way possible IMO.

    This document could be a good starting Point for learning scss:
    https://gist.github.com/fredsiika/2958726da1f94a9bd447f4f7bd03a852

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search