在我的列表中设置最后的第5个li

时间:2013-08-16 11:09:58

标签: wordpress css3 html-lists

我在wordpress上运行这个网站,列表是由插件生成的,但是我似乎无法改变最后一个li标签上的任何样式。

HTML

<div class="home">
    <p></p>
    <h4><li><a class="wp-super-faq-question-closed" id="wp-super-faq-question--0" href="http://www.statics-wanted.co.uk/statics4cash/?wp_super_faq=earn-an-extra-750-for-your-static-genuine-additional-bonus" title="…Earn an Extra £750* for your static, Genuine Additional Bonus!!!”" rel="question"><span class="wp-super-faq-triangle">▶</span> …Earn an Extra £750* for your static, Genuine Additional Bonus!!!”</a></li></h4>
    <div class="wp-super-faq-answer" id="wp-super-faq-question--0-answer" style="zoom: 1; display: none;">Enter answer here</div>
    <h4><li><a class="wp-super-faq-question-closed" id="wp-super-faq-question--1" href="http://www.statics-wanted.co.uk/statics4cash/?wp_super_faq=you-want-to-sell-your-static-fast-and-for-as-much-as-possible" title="“…You want to sell your static FAST and for as much as possible.”" rel="question"><span class="wp-super-faq-triangle">▶</span> “…You want to sell your static FAST and for as much as possible.”</a></li></h4>
    <div class="wp-super-faq-answer" id="wp-super-faq-question--1-answer" style="zoom: 1; display: none;">Enter answer here</div>
    <h4><li><a class="wp-super-faq-question-closed" id="wp-super-faq-question--2" href="http://www.statics-wanted.co.uk/statics4cash/?wp_super_faq=85-of-customers-received-more-money-by-using-us" title="“…85% of customers received more money by using us.”" rel="question"><span class="wp-super-faq-triangle">▶</span> “…85% of customers received more money by using us.”</a></li></h4>
    <div class="wp-super-faq-answer" id="wp-super-faq-question--2-answer" style="zoom: 1; display: none;">Enter answer here</div>
    <h4><li><a class="wp-super-faq-question-closed" id="wp-super-faq-question--3" href="http://www.statics-wanted.co.uk/statics4cash/?wp_super_faq=we-have-over-98-customer-satifaction" title="“…We have over 98% customer satifaction.”" rel="question"><span class="wp-super-faq-triangle">▶</span> “…We have over 98% customer satifaction.”</a></li></h4>
    <div class="wp-super-faq-answer" id="wp-super-faq-question--3-answer" style="zoom: 1; display: none;">Enter answer here</div>
    <h4><li><a class="wp-super-faq-question-closed" id="wp-super-faq-question--4" href="http://www.statics-wanted.co.uk/statics4cash/?wp_super_faq=last-year-we-spent-over-1million-buying-static-caravans" title="…Last year we spent over £1million buying Static Caravans" rel="question"><span class="wp-super-faq-triangle">▶</span> …Last year we spent over £1million buying Static Caravans</a></li></h4>
    <div class="wp-super-faq-answer" id="wp-super-faq-question--4-answer" style="zoom: 1; display: none;">Enter answer here</div>
    <p></p>
</div>

CSS

.home li {
    list-style:url(../images/fact.png);
}
.home h4 li:nth-child(5) {
    padding-top:20px
}

JSFiddle Link

非常感谢

2 个答案:

答案 0 :(得分:0)

问题是li不是第n个孩子,它们都在<h4>元素内。如果您使用:

.home h4:nth-child(10) li {padding-top: 20px;}

这应解决问题

答案 1 :(得分:0)

你可以创建一个css类

li.last-item { /* ... */ }

并将其应用于您的上一个列表项。