Search code examples
csssasscompass-sassscss-mixins

Sass - Siblings with diferent property and a common div style inside


Any help about how could I structure in a better way with sass this code? I would like to no repeat the classes names and nest the code if it's possible. Would appreciate a new vision of how to do it.

.vjs-carousel-left-button,
.vjs-carousel-right-button {
  position: absolute;
  top: 0;
  display: table;
  cursor: pointer;
  z-index: 3;
}

.vjs-carousel-left-button {
  left: 0;
}

.vjs-carousel-right-button {
  right: 0;
}

.vjs-carousel-left-button div,
.vjs-carousel-right-button div {
  display: table-cell;
  color: white;
  font-size: 5em;
}

Thank you


Solution

  • %vjs-carousel-button {
      position: absolute;
      top: 0;
      display: table;
      cursor: pointer;
      z-index: 3;
    
      div {
        display: table-cell;
        color: white;
        font-size: 5em;
      }
    }
    
    .vjs-carousel-left-button {
      @extend %vjs-carousel-button;
      left: 0;
    }
    
    .vjs-carousel-right-button {
      @extend %vjs-carousel-button;
      right: 0;
    }
    

    Check here https://www.sassmeister.com/gist/0cd54708851863215e4457c500881bb2