2

私はこのようなものを持っています:

<div id="someID">
   <div class="text">
     -----other html tags
   </div>
   <div class="text">
      -----other html tags
   </div>
   <div class="text">
     -----other html tags
   </div>
</div>

テキスト div 用の CSS もいくつかあります。テキストのクラスで 2 番目の div に別の CSS を設定することは可能ですか?

4

2 に答える 2

2

nth-child で簡単に行うことができます:

#someID .text:nth-child(2) {
 background:red;   
}

デモ: http://jsfiddle.net/P6FKf/

于 2013-08-27T17:35:36.667 に答える
1

疑似セレクタ nth-child ie を使用できますdiv.text:nth-child(2)

于 2013-08-27T17:36:03.160 に答える