Today I Learned - Rocky Kev

TIL functions in sass

POSTED ON:

TAGS:

You can declare functions in sass using @function.

You can even write for loops, return values, and even create @warn and @error.

Why? I'd say, why not?

$base-font-size: 16px;
$min-width: 320px;
$max-width: 1200px;

@function font-size($viewport-width) {
$font-size: $base-font-size + (($viewport-width - $min-width) / ($max-width - $min-width)) * 4rem;
@return $font-size;
}

h1 {
font-size: font-size(600px);
}

REF:
https://sass-lang.com/documentation/at-rules/function


Related TILs

Tagged:

TIL the alternate keyword

If 'alternate' appears along with the stylesheet keyword, the linked file is an alternative stylesheet. It won’t be applied to the document, but it will be ready for when we need it.

TIL Logical Properties

For that sweet sweet Internationalization you want to avoid directional words like 'left', 'right', 'top', and 'bottom'.

TIL Using pseudo-classes in your querySelector!

let notTuna = document.querySelectorAll('.sandwich:not(.tuna)')