階層のある目次などで見やすくするために下位の階層を折りたたみ(collapse)の機能で表示、非表示を切替えられると便利です。Bootstrap3の標準機能でリスト、リストグループ、パネルの階層を折りたたみ設定してみました。
リストを折りたたみ
<ol> <li> <a data-toggle="collapse" href="#list1"> 目次1 </a> <div id="list1" class="panel-collapse collapse"> <div class="panel-body"> <ol> <li> <a data-toggle="collapse" href="#list11"> 目次1-1 </a> <div id="list11" class="panel-collapse collapse"> <div class="panel-body"> <ol> <li>目次1-1-1</li> <li>目次1-1-2</li> <li>目次1-1-3</li> </ol> </div> </div> </li> <li>目次1-2</li> <li>目次1-3</li> </ol> </div> </div> </li> <li>目次2</li> <li>目次3</li> <li>目次4</li> </ol>
パネルグループを折りたたみ
<div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc1"> 目次1 </a> </h4> </div> <div id="acc1" class="panel-collapse collapse"> <div class="panel-body"> <div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc11"> 目次1ー1 </a> </h4> </div> <div id="acc11" class="panel-collapse collapse"> <div class="panel-body"> <div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc111"> 目次1ー1-1 </a> </h4> </div> <div id="acc111" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc112"> 目次1-1-2 </a> </h4> </div> <div id="acc112" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc113"> 目次1-1-3 </a> </h4> </div> <div id="acc113" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> </div> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc12"> 目次1-2 </a> </h4> </div> <div id="acc12" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc13"> 目次1-3 </a> </h4> </div> <div id="acc13" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> </div> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc2"> 目次2 </a> </h4> </div> <div id="acc2" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#acc3"> 目次3 </a> </h4> </div> <div id="acc3" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> </div>
リストグループを折りたたみ
<ul class="list-group"> <li class="list-group-item"> <a data-toggle="collapse" href="#lg1"> 目次1 </a> <div id="lg1" class="panel-collapse collapse"> <div class="panel-body"> <ul class="list-group"> <li class="list-group-item"> <a data-toggle="collapse" href="#lg11"> 目次1-1 </a> <div id="lg11" class="panel-collapse collapse"> <div class="panel-body"> <ul class="list-group"> <li class="list-group-item">目次1-1-1</li> <li class="list-group-item">目次1-1-2</li> <li class="list-group-item">目次1-1-3</li> </ul> </div> </div> </li> <li class="list-group-item">目次1-2</li> <li class="list-group-item">目次1-3</li> </ul> </div> </div> </li> <li class="list-group-item">目次2</li> <li class="list-group-item">目次3</li> <li class="list-group-item">目次4</li> </ul>