13.1. Sass tutorial

发布时间 :2024-02-26 23:00:06 UTC      

Image0

Sass (English full name: Syntactically Awesome Stylesheets) is a cascading stylesheet language originally designed by Hampton Catlin and developed by Natalie Weizenbaum.

Sass is a CSS preprocessor.

Sass is an CSS extension language that can help us reduce repetitive code in CSS and save development time.

Sass is fully compatible with all versions of CSS.

Sass extends CSS3, adding rules, variables, blending, selectors, inheritance, built-in functions, and so on.

Sass generates well-formatted CSS code that is easy to organize and maintain.

The Sass file suffix is .scss .

13.1.1. Sass instance

/* Define variables and values */
$bgcolor: lightblue;
$textcolor: darkblue;
$fontsize: 18px;

/* Define variables and values */
body {
  background-color: $bgcolor;
  color: $textcolor;
  font-size: $fontsize;
}

What you need to know before reading this tutorial:

To read this tutorial, you need to have the following foundations:

  • HTML tutorial

  • CSS tutorial

13.1.2. Why use Sass?

The syntax of CSS itself is not strong enough, resulting in repeated writing of some code, unable to achieve reuse, and it is not easy to maintain in the code.

Sass introduces a reasonable style reuse mechanism, adding rules, variables, blending, selectors, inheritance, built-in functions, and so on.

For example, we will reuse the hexadecimal color code many times in CSS. When you have a variable, if you want to change the color code, just change the value of the variable:

13.1.3. Sass instance

/* To define color variables and modify color values, just modify them here */
$primary_1: #a2b9bc;
$primary_2: #b2ad7f;
$primary_3: #878f99;

/* Using variables */
.main-header {
  background-color: $primary_1;
}

.menu-left {
  background-color: $primary_2;
}

.menu-right {
  background-color: $primary_3;
}

How does Sass work?

Browsers do not support Sass code. Therefore, you need to use a Sass preprocessor to convert Sass code into CSS code.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.