Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border radius Sass Mixin

Tags:

css

sass

mixins

At the time i use 2 Mixins for my Border Radius:

// When the Input is 1 Variable
@mixin border-radius($pixel) {
  border-radius: $pixel;
}

// When the Inputs are 4 Variables
@mixin border-radius-s($tl, $tr, $br, $bl) {
  border-top-left-radius: $tl;
  border-top-right-radius: $tr;
  border-bottom-right-radius: $br;
  border-bottom-left-radius: $bl;
}

I'm trying to find a way to combine those mixins in to one! Probably with an if else for the input. I've tried around but couldn't find any good working solution.

Anyone that could help me on that ?

like image 281
Mini John Avatar asked May 19 '14 19:05

Mini John


People also ask

What is mixin sass?

Sass MixinsThe @mixin directive lets you create CSS code that is to be reused throughout the website. The @include directive is created to let you use (include) the mixin.

What is @content in sass?

The @content, aka content directive, is “simple” in that it provides a way to reduce repetitive code, allowing for reuse and easier changes throughout the codebase.

Which arguments are used to include arguments in the Mixins?

Keyword arguments: The arguments are used to include in mixins. These types of arguments, if named, can be passed in any order and their default values can be skipped.


1 Answers

You can set the mixin to accept a list of values, as shown in the docs.

@mixin border-radius($pixel...) {
  border-radius: $pixel;
}
like image 102
Scimonster Avatar answered Oct 15 '22 01:10

Scimonster