Skip to content

Commit

Permalink
Merge pull request #59 from shotakaha/add-css-nest
Browse files Browse the repository at this point in the history
feat(html/css-nest.md): CSSネストを追加した
  • Loading branch information
shotakaha authored Dec 16, 2023
2 parents c0b2dcd + 4c38d3b commit e21540f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/source/html/css-nest.md
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)を確認すると、まだブラウザでフルサポートされていません。

:::
1 change: 1 addition & 0 deletions docs/source/html/html-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ html-jsonld
```{toctree}
css-selectors
css-variables
css-nest
css-font
css-display
css-margin
Expand Down

0 comments on commit e21540f

Please sign in to comment.