2016-07-26 9 views
0

ブログの投稿を表示するためにこのプラグインを使用したいと考えていますが、画像をバックグラウンドにする代わりに、クライアントは異なる色の画像を必要としています。ここの別のポストから、私はこれを行うと信じているコードを理解しましたが、それをウェブサイト上で取ることはできません!ここで私が作ったコードはここで働くようです。 Example where code is working.ポストグリッドレイアウトでランダムに異なる色の背景

ここに問題のウェブサイトがあります。 The div site where it isn't working like it should...

あなたはすべての色は、彼らが... どれでも有益な助言を大幅にこれが機能しない理由には理解されるであろうしなければならないように交互に同じではないことがわかります。

ここには、上記のjsfiddleにあるCSSとJSがあります。

CSS:

.custom_tdgclients_grid{width:20%;height:90px;display:inline-block} 
.custom_tdgclients_grid{background:#a7948b} 
.custom_tdgclients_grid:nth-child(2n){background-color:rgb(232, 73, 73)!important;} 
.custom_tdgclients_grid:nth-child(3n){background-color:rgb(83, 71, 65)!important;} 
.custom_tdgclients_grid:nth-child(4n){background-color:#e8d2af!important;} 
.custom_tdgclients_grid:nth-child(5n){background-color:rgb(131, 119, 113)!important;} 
.custom_tdgclients_grid:nth-child(6n){background-color:rgb(216, 184, 133)!important;} 
.custom_tdgclients_grid:nth-child(7n){background-color:rgb(201, 93, 93)!important;} 
.custom_tdgclients_grid:nth-child(8n){background-color:#e8d2af!important;} 

とJavaScript:

$('.custom_tdgclients_grid:nth-child(2n)').css({'background-color':'rgb(232, 73, 73)'}); 
$('.custom_tdgclients_grid:nth-child(3n)').css({'background-color':'rgb(83, 71, 65)'}); 
$('.custom_tdgclients_grid:nth-child(4n)').css({'background-color':'#e8d2af'}); 
$('.custom_tdgclients_grid:nth-child(5n)').css({'background-color':'rgb(131, 119, 113)'}); 
$('.custom_tdgclients_grid:nth-child(6n)').css({'background-color':'rgb(216, 184, 133)'}); 
$('.custom_tdgclients_grid:nth-child(7n)').css({'background-color':'rgb(201, 93, 93)'}); 
$('.custom_tdgclients_grid:nth-child(8n)').css({'background-color':'rgb(181, 128, 101)'}); 

答えて

1

削除してくださいn2nから `3N、等...

それが識別しようと動作しない場合両親のように:
#parent .custom_tdgclients_grid:nth-child(2)

希望、それは働くでしょう:)

+0

divウェブサイトを見ると、親は何だと思いますか?彼らの素敵なワードプレスの短いコードではあまりにも多くのことが起こっていますが、どちらが親であるかわかりません。私は** n **を削除しようとしましたが、そのままコードを使用しましたが、何も変更されませんでした。 – Tyrii

+0

これを簡略化しましたが、まだ動作していないようです。 .vc_gitem-zone.custom_tdgclients_grid:nth-​​child(1){背景色:#a7948b;} – Tyrii

0

私はこれを修正するためのコードを考え出しました。私はそれを必要とするかもしれない誰のためにここに投稿するつもりです。両親と一緒にそれらを特定することが重要だと私は思う!

#x-content-band-4 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(1) .custom_tdgclients_grid {background-color: #a7948b;} 
#x-content-band-4 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(2) .custom_tdgclients_grid { background-color: rgb(232, 73, 73);} 
#x-content-band-4 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(3) .custom_tdgclients_grid { background-color: rgb(83, 71, 65);} 
#x-content-band-4 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(4) .custom_tdgclients_grid { background-color: #e8d2af;} 
#x-content-band-5 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(1) .custom_tdgclients_grid { background-color: rgb(131, 119, 113);} 
#x-content-band-5 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(2) .custom_tdgclients_grid { background-color: rgb(216, 184, 133);} 
#x-content-band-5 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(3) .custom_tdgclients_grid { background-color: rgb(201, 93, 93);} 
#x-content-band-5 .vc_grid .vc_pageable-slide-wrapper .vc_grid-item:nth-child(4) .custom_tdgclients_grid { background-color: #e8d2af;} 

JSサイドコードについても同様の操作を行います。

+0

これは私が言ったことです... – KillianC

関連する問題