我需要選擇'inner'類的第一個匹配項,並在其上應用css。 我嘗試過:第一胎和第一胎,但有些不正確。 請幫忙。 我在尋找什麼是一樣的東西如何在css的頁面上選擇第一次出現的內部類?
.inner:first-occurrence
我嘗試以下,和其他類似的組合 -
.outer:nth-child(1) .inner:nth-child(1){}
.outer:nth-child(1) .inner:first-child{}
.outer:nth-of-type(1) .inner{}
.outer:nth-child(1) .inner:nth-of-type(1){}
.inner:first-of-type(){}
.row .inner:firs-of-type{}
.row .inner:first-child{}
HTML
<div class="row">
<div class="outer col-xs-9">
<div>some text 1</div>
<div class="inner">
... --select this--
</div>
</div>
<div class="outer col-xs-3">
<div>some text 2</div>
<div class="inner">
...
</div>
</div>
</div>
.outer.col-XS-9 .inner否則是不可能的CSS選擇 – Gerard
你不能給它一個id?你的div是動態創建的? – Badiparmagi
@Badiparmagi yes div是動態創建的,因此無法指定id,寬度類.col-xs-9也是動態的。 – Neelotpal