LESS Nested Properties

Out of curiosity:
Are nested properties possible in LESS? Since SASS supports this feature ( Nested Properties )

div {
  background: {
    size: cover;
    color: green;
  }
}

      

TO

div {
  background-size: cover;
  background-color: green;
}

      

+3


source to share


1 answer


Looking at the documentation, it seems that this is not possible. But you can easily create a mixin that works the same way .



.setBackground( @color: green; @image: ''; @repeat: no-repeat; @position: center; @size: '' ) {
  background: @color @repeat @position;

  & when not ( @image = '' ) {
    background-image: @image;
  }

  & when not ( @size = '' ) {
    background-size: @size;
  }
}

div {
  .setBackground(
    @color: yellow;
    @image: url( some-image.png );
    @repeat: repeat;
    @size: cover;
  );
}

      

0


source







All Articles