-
Notifications
You must be signed in to change notification settings - Fork 0
SASS
kitiya edited this page Apr 13, 2020
·
9 revisions
- SCSS Tutorial
- 7 Sass techniques to help you write better code
- Structuring your Sass Projects
- css-tricks: Sass Techniques from the Trenches
- GitHub: Bootstrap Mixins
@mixin breakpoint($class) {
@if $class == xs {
@media (max-width: 767px) { @content; }
}
@else if $class == sm {
@media (min-width: 768px) { @content; }
}
@else if $class == md {
@media (min-width: 992px) { @content; }
}
@else if $class == lg {
@media (min-width: 1200px) { @content; }
}
@else if $class == xl {
@media (min-width: 1800px) { @content; }
}
@else {
@warn "Breakpoint mixin supports: xs, sm, md, lg, xl";
}
}aside.primary {
float: right;
width: 350px;
@include breakpoint(sm) {
float: none;
width: 100%;
}
}First and foremost, RFS needs to be installed on the project. It’s available in npm and Yarn:
npm install rfs
styles.scss
/* import the rfs mixin */
@import "~rfs/scss";
body {
@include font-size(20px);
@include font-size(1.125rem);
}
h1 {
@include font-size(50px);
@include font-size(4.5rem);
}
h2 {
@include font-size(40px);
@include font-size(3.75rem);
}
h3 {
@include font-size(30px);
@include font-size(1.5rem);
}Both px and rem units are also supported. If a value without a unit is passed, px is used by default. The font sizes are always rendered in rem (in combination with vw) to make sure the font sizes also increase when the default font size is increased in the browser (this is a feature often used by visually impaired people).