2

任何建议如何选择 Bootstrap 折叠模块的第一个和最后一个孩子?我需要首先和最后选择“.accordion-heading”..

  <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

1 回答 1

4

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

你必须先去accordion-group,然后参考accordion-headingThere's gonna be the only one element with class accordion-heading:)

.accordion-group:first-child .accordion-heading a{color: #f00;}
.accordion-group:last-child .accordion-heading a{color: #0f0;}
于 2012-06-11T14:06:44.380 回答