2012-06-11 79 views
2

任何建議如何選擇Bootstrap崩潰模塊的第一個和最後一個孩子?我需要選擇「.accordion,標題爲」第一個和最後..Bootstrap崩潰用css選擇第一個和最後一個孩子

<div id="accordion2" class="accordion"> 
<div class="accordion-group"> 
    <div class="accordion-heading"><a class="accordion-toggle" href="#collapseOne" data-toggle="collapse" data-parent="#accordion2"><br /> 
    Toggle Accordion 1<br /> 
    </a></div> 
    <div id="collapseOne" class="accordion-body in collapse" style="height: auto;"> 
    <div class="accordion-inner"> 
     <p>Content 1</p> 
    </div> 
    </div> 
</div> 
<div class="accordion-group"> 
    <div class="accordion-heading"><a class="accordion-toggle" href="#collapseTwo" data-toggle="collapse" data-parent="#accordion2"><br /> 
    Toggle Accordion 2<br /> 
    </a></div> 
    <div id="collapseTwo" class="accordion-body collapse" style="height: 0px;"> 
    <div class="accordion-inner"> 
     <p>Content 2</p> 
    </div> 
    </div> 
</div> 
<div class="accordion-group"> 
    <div class="accordion-heading"><a class="accordion-toggle" href="#collapseThree" data-toggle="collapse" data-parent="#accordion2"><br /> 
    Toggle Accordion 3<br /> 
    </a></div> 
    <div id="collapseThree" class="accordion-body collapse" style="height: 0px;"> 
    <div class="accordion-inner"> 
     <p>Content 3</p> 
    </div> 
    </div> 
</div> 

回答

4

http://jsfiddle.net/PzB8D/1/

你必須去accordion-group,再參考accordion-heading有會是唯一的一個元素與accordion-heading類:)

.accordion-group:first-child .accordion-heading a{color: #f00;} 
.accordion-group:last-child .accordion-heading a{color: #0f0;} 
相關問題