2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Nest CSS with Sass
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Nest CSS with Sass
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Problem Explanation
|
2018-10-12 15:37:13 -04:00
|
|
|
- In Sass, nesting CSS rules allows to define hierarchy selectors.
|
|
|
|
- You can organize your style sheets by nesting CSS rules.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
**Example:**
|
|
|
|
|
|
|
|
```scss
|
2018-10-12 15:37:13 -04:00
|
|
|
.title{
|
|
|
|
strong{}
|
|
|
|
em{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This will be compiled into:
|
|
|
|
|
|
|
|
.title{}
|
|
|
|
.title strong{}
|
|
|
|
.title em{}
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
- You may want to change the position of "}" at line 4.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
|
|
|
|
|
|
|
```scss
|
2018-10-12 15:37:13 -04:00
|
|
|
<style type='text/sass'>
|
|
|
|
.blog-post {
|
|
|
|
h1 {
|
|
|
|
text-align: center;
|
|
|
|
color: blue;
|
|
|
|
}
|
|
|
|
p {
|
|
|
|
font-size: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|