1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

よく使うCSS結合子

1
Last updated at Posted at 2017-07-20

概要

よく使うCSS結合子です。
(sassで記述しています。)

結合子

セレクタを結合子で組み合わせると、シーン別に個別に指定をすることができます。
やり過ぎるとメンテナンス性が著しく悪くなるので、シンプルに使うことがポイントです。

A B

子孫セレクタ。
A要素の子孫であるすべてのB要素に適用されます。

.sass
div p
  color: red

A > B

子セレクタ。
A要素の子であるすべてのB要素に適用されます。

.sass
div > p
  color: red

A + B

隣接セレクタ。
A要素の直後に現れるB要素のみに適用されます。

.sass
h2 + p
  color: red

A ~ B

間接セレクタ。
A要素のあとに現れるB要素のみに適用されます。

.sass
h2 ~ p
  color: red
1
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?