Home > Back-end >  How to add add condition in mixin
How to add add condition in mixin

Time:10-18

I have one mixin for width and height. Here is my code.

<div  id="ele1">test</div>
<div  id="ele2">test2</div>
<div  id="ele3">test2</div>
@mixin size($width, $height: $width) {
  width: $width;
  height: $height;
}
#ele1 {
  @include size(80px);
}    
#ele2 {
  @include size(80px, 180px);
}
#ele3 {
  @include size(80px, auto);
}
.element{
  background:blue;
  margin:10px;
  color:#fff;
  float:left;
  padding:20px;
}

output

Reference : SASS Conditional Rendering

  • Related