4 flexible Scss compilation output styles

4 flexible Scss compilation output styles

Many people have been told how to compile from the moment they use Scss. Therefore, there is basically only one command compilation method. In fact, Scss provides 4 styles of CSS output to meet the needs of more people. The different output modes are as follows:

  • Nested output mode nested
  • Expanded output mode
  • Compact output mode
  • Compressed output mode compressed

Then, you can use parameters at will to generate your favorite CSS style.

1. nested

nested is a nested output style, that is, the left curly brace and the CSS class name (the first line) are aligned. The right curly brace is aligned with the last line, without wrapping.

This style is generally used less frequently because not many people normally write CSS in this way and the style is rather awkward.

The compilation command is:

sass abc.scss:abc.css --style nested

Generates the following result:

.header {
  background: #f00;
  color: #000;
  font-size: 20px; }
.sidebar {
  float: left;
  width: 300px;
  height: 500px; }
.main {
  float: right;
  width: 800px;
  padding: 20px;
  min-height: 500px; }

2. expanded

Expanded is the expanded output mode, which is also a style commonly used by front-end developers to write CSS directly. The left curly brace is aligned with the first line and does not wrap. The right curly brace ends on a new line.

The compilation command is:

sass abc.scss:abc.css --style expanded

Generates the following result:

.header {
  background: #f00;
  color: #000;
  font-size: 20px;
}
.sidebar {
  float: left;
  width: 300px;
  height: 500px;
}
.main {
  float: right;
  width: 800px;
  padding: 20px;
  min-height: 500px;
}

3.compact

Compact is a compact output method, and is another method that is often used by front-end developers to write CSS directly. The left and right curly braces do not wrap. The CSS property values ​​within the curly braces are not wrapped and are written one after another.

It is very friendly to friends who prefer to write single-line CSS.

The compilation command is:

sass abc.scss:abc.css --style compact

Generates the following result:

.header { background: #f00; color: #000; font-size: 20px; }
.sidebar { float: left; width: 300px; height: 500px; }
.main { float: right; width: 800px; padding: 20px; min-height: 500px; }

4. compressed

compressed is the compressed output mode. All its contents are not wrapped, and all comments and whitespace are removed. Crush all the code into one ball.

It is usually used in online situations, or when there is no need to read or modify CSS files at all. The file will be smaller.

The compilation command is:

sass abc.scss:abc.css --style compressed

Generates the following result:

.header{background:#f00;color:#000;font-size:20px}.sidebar{float:left;width:300px;height:500px}.main{float:right;width:800px;padding:20px;min-height:500px}

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  Complete step record of vue encapsulation TabBar component

>>:  How to recover data after accidentally deleting ibdata files in mysql5.7.33

Recommend

Float and Clear Float in Overview Page

1. Float: The main purpose is to achieve the effe...

How to solve the problem of forgetting the root password of Mysql on Mac

I haven't used mysql on my computer for a lon...

CSS3 realizes the graphic falling animation effect

See the effect first Implementation Code <div ...

What you need to understand about MySQL locks

1. Introduction MySQL locks can be divided into g...

HTML background color gradient effect achieved through CSS style

Effect screenshots: Implementation code: Copy code...

CSS makes tips boxes, bubble boxes, and triangles

Sometimes our pages will need some prompt boxes o...

Six important selectors in CSS (remember them in three seconds)

From: https://blog.csdn.net/qq_44761243/article/d...

Docker container custom hosts network access operation

Adding the extra_hosts keyword in docker-compose....

Detailed explanation of html download function

The new project has basically come to an end. It ...

Vue implements partial refresh of the page (router-view page refresh)

Using provide+inject combination in Vue First you...

A practical record of checking and processing duplicate MySQL records on site

Table of contents Preface analyze Data Total Repe...

mysql-8.0.17-winx64 deployment method

1. Download mysql-8.0.17-winx64 from the official...

A brief analysis of HTML space code

How much do you know about HTML? If you are learni...

6 interesting tips for setting CSS background images

Background-image is probably one of those CSS pro...