我想在可摺疊面板中使用Bootstrap Scrollspy。一切似乎都在起作用,除非藥片在點擊它們時不更新/更改顏色。我想我必須改變CSS,但我不確定我需要改變。如何使用Bootstrap Scrollspy獲取背景顏色以更新葯丸?
HTML
<body>
<div class="container">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
Title 1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<div class="row">
<nav class="col-sm-3" id="myScrollspy">
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="#Subtitle1">Subtitle1</a></li>
<li><a href="#Subtitle2">Subtitle2</a></li>
<li><a href="#Subtitle3">Subtitle3</a></li>
<li><a href="#Subtitle4">Subtitle4</a></li>
<li><a href="#Subtitle5">Subtitle5</a></li>
<li><a href="#Subtitle6">Subtitle6</a></li>
<li><a href="#Subtitle7">Subtitle7</a></li>
</ul>
</nav>
<div class="col-sm-9">
<div id="Subtitle1">
<h1>Subtitle1</h1>
<p>some text</p>
</div>
<div id="Subtitle2">
<h1>Subtitle2</h1>
<p>some text</p>
</div>
<div id="Subtitle3">
<h1>Subtitle3</h1>
<p>some text</p>
</div>
<div id="Subtitle4">
<h1>Subtitle4</h1>
<p>some text</p>
</div>
<div id="Subtitle5">
<h1>Subtitle5</h1>
<p>some text</p>
</div>
<div id="Subtitle6">
<h1>Subtitle6</h1>
<p>some text</p>
</div>
<div id="Subtitle7">
<h1>Subtitle7</h1>
<p>some text</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
Title 2
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle = "collapse" data-parent = "#accordion" href = "#collapseThree">
Title 3
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body">
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.
</div>
</div>
</div>
</div>
</div>
<!-- /container -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
CSS
body {
position: relative;
}
ul.nav-pills {
top: 50px;
position: fixed;
}
div.col-sm-9 div {
height: 250px;
font-size: 28px;
}
感謝。我明白你的意思了。它現在跳到最後一個按鈕上。有沒有這方面的工作? – MrAutoIt