我想帶班第一克元素「V-數據點的V形變,數據點」目標內的RECT元素 - 所以我想強調的只是rect元素1。看到我的CSS代碼如下:CSS - 如何定位類的第一個實例中的所有元素?
<g class="v-datapoint-group">
<g>
<g class="v-datapoint v-morphable-datapoint">First</g>
<rect>1</rect>
<g class="v-datapoint v-morphable-datapoint">Second</g>
<rect>2</rect>
<g class="v-datapoint v-morphable-datapoint">Third</g>
</g>
</g>
任何人都可以請幫助如何正確地做到這一點?我試過以下內容:
g.v-datapoint-group g.v-datapoint.v-morphable-datapoint {
background-color:yellow;
} /* highlights word First, Second, Third */
g.v-datapoint-group g.v-datapoint.v-morphable-datapoint rect {
background-color: yellow;
} /* doesn't do anything */
g.v-datapoint-group g.v-datapoint.v-morphable-datapoint:first-child {
background-color: yellow;
} /* highlights word First */
g.v-datapoint-group g.v-datapoint.v-morphable-datapoint:first-child rect {
background-color: yellow;
} /* doesn't do anything */
g.v-datapoint-group rect {
background-color: yellow;
} /* highlights both 1 & 2 */
g.v-datapoint-group rect:first-child {
background-color: yellow;
} /* doesn't do anything */
任何想法如何定位矩形元素1?
感謝, 阿加塔
嘗試使用'!important' – TricksfortheWeb
@Ticks.comheWeb!重要的是應該避免不惜一切代價。 –
反正沒有必要... – TricksfortheWeb