0
0

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 3 years have passed since last update.

[CSS]ぷよぷよするお寿司()のセレクターを的確に選び出す[ぷよぷよ前編]

Posted at

目的

  • 実務的なHTMLを使う時の感情を、複雑で混乱する嫌な気持ち→簡単な気持ちに変化させる。
  • CSSでセレクタを適切に選び出せる。

今日やること

ぷよぷよ寿司ゲーム
https://flukeout.github.io
※正確には寿司ではありませんwww

ezgif.com-video-to-gif.gif

学び

A.className level 7 of 32

Aタグのクラス名に一致する要素を選択する。

Screen Shot 2020-07-05 at 18.39.40.png

小さいオレンジのみ選択しろ

orange.small

注意

親子で指定するのか、子のクラスだけで指定するのかを間違えやすい。
たとえば、"弁当のオレンジ"を指定したい場合は、下記記述

bento .small

A * level 11 of 32

Aの中にある要素を選択する。

Screen Shot 2020-07-05 at 18.48.54.png

plateに乗っている要素を選択しろ

plate *

注意

plate

だと、中の要素ではなくplate自身が選択される。

A + B level 12 of 32

Aの直後にあるBを選択する。

Screen Shot 2020-07-05 at 18.53.17.png

**plateの直後のりんごを選択しろ

plate + apple

A > B level 14 of 32

Aの中にある要素Bを選択する。

Screen Shot 2020-07-05 at 18.56.17.png

皿の上にあるリンゴを選択しろ

plate > apple

:first-child level 15 of 32

最初の子要素を選択する。

Screen Shot 2020-07-05 at 18.57.29.png

皿の一番上のオレンジを選択しろ

plate :first-child

***注意

これはなぜ一番下がfirstchildではないのか(HTML上は確かに一番上がfirstchild)が理解できていない。

:only-child level 16 of 32

兄弟要素がない子要素を選択する。

Screen Shot 2020-07-05 at 19.01.27.png

皿の上のリンゴときゅうりを選択しろ

plate :only-child

:nth-child(A) level 18 of 32

A番目の子要素を選択する。

Screen Shot 2020-07-05 at 19.04.33.png

3番目の皿を選択しろ

plate:nth-child(3)

:nth-last-child(A) level 19 of 32

??

Screen Shot 2020-07-05 at 19.06.01.png

これはうまくできませんでした。
明日もまたやろう。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?