0

リストがあり、色を変更して余白を削除するには、他のすべてのアイテムが必要です。私はn番目の子を使用しましたが、IE7-8以外のすべてで完全に機能します。n番目の子をサポートしていないことを知っているので、Jqueryを使用しました。

私はこれを見つけました::nth-childはIEで動作していません そしてこれ:http://verboselogging.com/2010/01/17/making-nth-child-work-everywhere

それらを実装しようとしましたが、まだ機能していません。ここで表示できます: http ://www.dffernandez.com/client_review_files/tests/nth-child.html

#prop-images-wrapper {
float: left;
margin-bottom: 0.6em;
background-color: #F00;
width: 340px;
margin-right: 5px;}

#prop-images-wrapper li:nth-child(2n+1), .difcolor {
margin-right: 0px;
background-color: #06F;}

-

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>$(document).ready(function(){
$("#prop-images-wrapper li:nth-child(2n+1)").addClass("difcolor");
});</script>

前もって感謝します。

4

2 に答える 2

0

テストページにjqueryをロードするのを忘れました。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

http://jsfiddle.net/m6vnt/1/

于 2012-11-29T17:16:54.823 に答える
0

jqueryを使用してn番目の子を設定している場合は、cssブロックとjqueryのコードを使用する代わりに、すべてにjqueryを使用します。

次のjsfiddleをチェックしてください

http://jsfiddle.net/RjGpC/1/

この次の行で

#prop-images-wrapper li:nth-child(2n+1), .difcolor {

削除するだけですli:nth-child(2n+1),

于 2012-11-29T17:24:19.003 に答える