SCSS Introduction

β€” 3 minute read

permalink

Hey Guys, I realized I've been using SCSS in most of my Codepens. But we never really touched based on this topic.

So let's dive into introducing SCSS to you all.

BTW: I have a free Giveaway on Twitter! 🚨 Free Giveaway

What Does SCSS Mean? permalink

It stands for sassy css and is basically the follow up for SASS stylesheets. You will find many people calling it SASS or SCSS, but either way, they are very similar and used for modular CSS setup.

In general, some common use cases are:

  • Variables
  • Nesting
  • @import
  • @mixin
  • @extend

We won't be going through all these topics today, but I will touch base on them during the next couple of days.

How Does SCSS Work permalink

A major thing to keep in mind is that a browser won't understand SCSS or SASS code. We need to process it and turn it into regular CSS files.

There are several ways to do this; the simplest is using a pre-processing plugin, for instance for Visual Studio:

Download Sass Compiler

This will run in Visual Studio and compile your SCSS files into one CSS file.

There are also specific SASS compilers see the website for more information:

SASS Compilers

Our First SCSS Example permalink

Let's get right in there with a very basic example:

<div class="container">
<div class="box">
🀩 SCSS 🀩
</div>
</div>
$primary: #ffd670;
$secondary: #ff9770;

.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: $primary;
}

.box {
background: $secondary;
padding: 50px;
border-radius: 20px;
color: $primary;
font-size: 2rem;
font-weight: bold;
}

As you can see, we can now quickly change our colors, instead of having them repeating in every element styling.

This will result in the following Codepen.

See the Pen SCSS Introduction by Chris Bongers (@rebelchris) on CodePen.

Thank you for reading, and let's connect! permalink

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter