2
2

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 1 year has passed since last update.

【CSS】:has()の使い方

Posted at

子孫要素に特定のクラスを持つdiv

div:has(.sample)

sampleというクラスが子孫要素にあるdivを対象にできます。

,で区切ることで複数のクラスを指定できます。

div:has(.sample, .example)

子要素が特定の要素のdiv

div:has(> p)

pが子要素であるdivが対象。

直後に特定の要素があるdiv

div:has(+ p)

直後にpがあるdivが対象になります。

2
2
0

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?