CSS Diner想必很多人听过,这是一个练习CSS中的选择器的不错的网站,最近在学习前端,打算好好写一下
常用英文单词:
plate
第一题右边的提示是类别选择器,选择plate
则会把所有plate
选中(好像说了句废话)。这里强调一点,题目的plate
并不是HTML/CSS的标签之类的,只是题目需要
bento
#fancy
plate>apple
或者plate apple
#fancy pickle
.small
orange.small
bento orange.small
plate,bento
*
plate + apple
bento ~ pickle
两种兄弟选择器:
两种后代选择器:
pickle > apple
orange:first-child
注意这题的答案不能是plate:first-child
,因为首先要选中该类,然后再是该类的限制
apple:only-child,plate>pickle
这题我的答案比较简单,网上有更好的答案:plate>:only-child
apple:last-child,pickle:last-child
plate:nth-child(3)
bento:nth-last-child(3)
first-child
区别开来,因为这里并不要紧接着父元素,答案是apple:first-of-type
plate:nth-of-type(2n)
plate:nth-of-type(2n+3)
apple:only-of-type
orange:last-of-type,apple:last-of-type
bento:empty
apple:not(.small)
plate[for]
for="Vitaly"
[for^="Sa"]
[for$="to"]