我仍然知道引导程序。如何修改我的代码,以便单击可折叠字段将折叠<li>
标记(accordion)中的其他字段。我知道您必须使用data-parent
值,但是,在进行实验时,我无法让它崩溃。
示例:点击“用户”链接后,关闭“学习单元”和“注册”部分
<li>
<a class="admin collapsed sidebar-parent" data-toggle="collapse" href="#sidebar-admin" style="border-top: none;"><i class="fa fa-wrench" style="margin-right: 17px; margin-left: 1px;"></i>Admin</a>
<ul id="sidebar-admin" class="nav collapse">
<li>
<!-- Users -->
<a class="users collapsed sidebar-subparent" data-toggle="collapse" href="#sidebar-users"> <i class="fa fa-user" style="margin-right: 15px; margin-left: 2px;"></i>Users</a>
<ul id="sidebar-users" class="nav collapse">
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/Users")"> <i class="fa fa-search" style="margin-right: 8px;"></i> Search Users</a>
</li>
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/NewUser")"> <i class="fa fa-plus-circle" style="margin-right: 12px;"></i> Add Users</a>
</li>
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/Roles")"> <i class="fa fa-users" style="margin-right: 10px; margin-left: -1px;"></i> Assign Roles</a>
</li>
</ul>
<!-- Units -->
<a class="unitsofstudy collapsed sidebar-subparent" data-toggle="collapse" href="#sidebar-units"> <i class="fa fa-university" style="margin-right: 12px;"></i>Units of Study</a>
<ul id="sidebar-units" class="nav collapse">
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/Units")"> <i class="fa fa-search" style="margin-right: 8px;"></i> Search Units</a>
</li>
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/NewOfferedUnit")"> <i class="fa fa-plus-circle" style="margin-right: 10px;"></i> Register Units</a>
</li>
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/NewUnit")"> <i class="fa fa-plus-circle" style="margin-right: 10px;"></i> Register Semester</a>
</li>
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/NewSemester")"> <i class="fa fa-plus-circle" style="margin-right: 10px;"></i> Offer Units</a>
</li>
</ul>
<!-- Enrolments -->
<a class="enrolments collapsed sidebar-subparent" data-toggle="collapse" href="#sidebar-admenrolments"> <i class="fa fa-graduation-cap" style="margin-right: 12px; margin-left: -2px;"></i>Enrolments</a>
<ul id="sidebar-admenrolments" class="nav collapse">
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/Enrolments")"> <i class="fa fa-search" style="margin-right: 8px;"></i> Search Enrolments</a>
</li>
<li class="sidebar-element">
<a href="@Url.Content("~/Admin/NewEnrolment")"> <i class="fa fa-plus-circle" style="margin-right: 10px;"></i> Enrol Students</a>
</li>
</ul>
</li>
</ul>
</li>
答案 0 :(得分:1)
手风琴行为取决于panel
类(http://getbootstrap.com/javascript/#collapse-options)。因此,父#sidebar-admin
的直系孩子必须是.panel
..
http://www.codeply.com/go/Zq1utEY3dV
<ul id="sidebar-admin" class="nav collapse">
<li class="panel">
<a class="users collapsed sidebar-subparent" data-toggle="collapse" data-parent="#sidebar-admin" href="#sidebar-users"> <i class="fa fa-user" style="margin-right: 15px; margin-left: 2px;"></i>Users</a>
<ul id="sidebar-users" class="nav collapse">
<li class="sidebar-element">
...