开发者

CSS argument for "if first child is"

开发者 https://www.devze.com 2023-03-20 23:37 出处:网络
I need a CSS selector for inside a div开发者_如何转开发 but I want it to only select the element if its the first element of a specific class inside that div.As your title implies \"if first child is\

I need a CSS selector for inside a div开发者_如何转开发 but I want it to only select the element if its the first element of a specific class inside that div.


As your title implies "if first child is": div > .test:first-child will select the first child of any <div> if it has the class test.

But if the first child of the <div> doesn't have the class test, then it won't continue searching the <div> until it finds a child with the class test — it just won't match anything. I'm not sure if that's what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消