2013-04-22 128 views
0

我想要選擇我的div畫廊中的每一個第四個圖像。我似乎無法弄清楚爲什麼我不能選擇它。不知道爲什麼:nth類型將不起作用

#gallery img:nth-of-type(4n){ 
    border: 5px solid #000; 
} 

我已經嘗試了一些其他的想法,但沒有成功。任何人都可以幫助我,並向我解釋爲什麼這不是選擇我的div畫廊中的每個第4個圖像?提前致謝。

<div id="gallery"> 

    <a href="/system/images/series_uploads/5/original/ankara_5602p_alabaster.jpg?1330114093" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/5/gallery/ankara_5602p_alabaster.jpg?1330114093" title="Ankara" /> 
    <div class="gallery-text"> 
     <h3>Ankara</h3> 
     <p>Porcelain</p> 
    </div> 
    </a> 

    <a href="/system/images/series_uploads/6/original/ankara_5624p_noce.jpg?1330114095" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/6/gallery/ankara_5624p_noce.jpg?1330114095" title="Ankara" /> 
    <div class="gallery-text"> 
     <h3>Ankara</h3> 
     <p>Porcelain</p> 
    </div> 
    </a> 

    <a href="/system/images/series_uploads/7/original/ashton_23931_smokey_beige_.jpg?1330114250" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/7/gallery/ashton_23931_smokey_beige_.jpg?1330114250" title="Ashton" /> 
    <div class="gallery-text"> 
     <h3>Ashton</h3> 
     <p>Porcelain</p> 
    </div> 
    </a> 

    <a href="/system/images/series_uploads/8/original/ashton_23942_camel_haze_entry.jpg?1330114251" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/8/gallery/ashton_23942_camel_haze_entry.jpg?1330114251" title="Ashton" /> 
    <div class="gallery-text"> 
     <h3>Ashton</h3> 
     <p>Porcelain</p> 
    </div> 
    </a> 

    <a href="/system/images/series_uploads/9/original/ashton_23942_camel_haze_lr.jpg?1330114252" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/9/gallery/ashton_23942_camel_haze_lr.jpg?1330114252" title="Ashton" /> 
    <div class="gallery-text"> 
     <h3>Ashton</h3> 
     <p>Porcelain</p> 
    </div> 
    </a> 

    <a href="/system/images/series_uploads/10/original/berkshire_25525_oak.jpg?1330115116" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/10/gallery/berkshire_25525_oak.jpg?1330115116" title="Berkshire" /> 
    <div class="gallery-text"> 
     <h3>Berkshire</h3> 
     <p>HDP &ndash; High Definition Porcelain</p> 
    </div> 
    </a> 

    <a href="/system/images/series_uploads/11/original/berkshire_25585_walnut_famousdaves01.jpg?1330115118" rel="lightbox['gallery']"> 
    <img alt="" src="/system/images/series_uploads/11/gallery/berkshire_25585_walnut_famousdaves01.jpg?1330115118" title="Berkshire" /> 
    <div class="gallery-text"> 
     <h3>Berkshire</h3> 
     <p>HDP &ndash; High Definition Porcelain</p> 
    </div> 
    </a> 
</div> 
+2

請張貼的HTML標記藏漢,因爲沒有什麼錯在這裏的代碼,有可能是其中的問題是在 – Breezer 2013-04-22 17:23:17

+0

遺憾關於那個。 – Jarrod 2013-04-22 17:26:02

+0

那裏更新了答案 – Breezer 2013-04-22 17:28:58

回答

4

他們不是兄妹,這就是爲什麼你應該使用

#gallery a:nth-of-type(4n) img{ 
    border: 5px solid #000; 
} 
+0

謝謝你的幫助! – Jarrod 2013-04-22 17:29:37

+1

歡迎,如果它的工作,請將其標記爲已回答,以便將來的用戶可以參與其中。關心=) – Breezer 2013-04-22 17:30:47

相關問題