-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from shotakaha/add-css-nest
feat(html/css-nest.md): CSSネストを追加した
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# ネストしたい | ||
|
||
```css | ||
|
||
:root { | ||
--color-text-main: black; | ||
--color-text-active: blue; | ||
} | ||
|
||
a { | ||
display: inline flow-root; | ||
color: var(--color-text-main); | ||
text-decoration: none; | ||
|
||
&:hover { | ||
color: var(--color-text-active); | ||
} | ||
} | ||
``` | ||
|
||
スタイルを入れ子構造で記述できます。 | ||
入れ子にすることで、スタイルの適用範囲が分かりやすくなります。 | ||
|
||
上記サンプルのように、リンクにホバーしたときに文字色を変えたい場合は、書くのがとても楽になりました。 | ||
|
||
:::{note} | ||
|
||
これまでの書き方だと、以下のようになります。 | ||
|
||
```css | ||
a { | ||
display: inline flow-root; | ||
text-decoration: none; | ||
color: var(--color-text-main); | ||
} | ||
|
||
a:hover { | ||
color: var(--color-text-active); | ||
} | ||
``` | ||
|
||
::: | ||
|
||
:::{note} | ||
|
||
[Can I use](https://caniuse.com/mdn-css_selectors_nesting)を確認すると、まだブラウザでフルサポートされていません。 | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ html-jsonld | |
```{toctree} | ||
css-selectors | ||
css-variables | ||
css-nest | ||
css-font | ||
css-display | ||
css-margin | ||
|