13.4. Sass nesting rules and attributes

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

Sass nested CSS selectors are similar to HTML’s nesting rules.

As follows, we nest the style of a navigation bar:

13.4.1. Sass Code:

nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  li {
    display: inline-block;
  }
  a {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
  }
}

In the instance, the selectors for ul , li , and a are all nested within the nav selectors.

Convert the above code to CSS code, as follows:

13.4.2. Css Code:

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
nav li {
  display: inline-block;
}
nav a {
  display: block;
  padding: 6px 12px;
  text-decoration: none;
}

Sass nesting properties

Many CSS attributes have the same prefix, for example: font-family , font-size and font-weight text-align , text-transform and text-overflow .

In Sass, we can write them using nested attributes:

13.4.3. Sass code:

font: {
  family: Helvetica, sans-serif;
  size: 18px;
  weight: bold;
}
text: {
  align: center;
  transform: lowercase;
  overflow: hidden;
}

Convert the above code to CSS code, as follows:

13.4.4. Css Code:

font-family: Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
text-align: center;
text-transform: lowercase;
text-overflow: hidden;

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.