如何将下拉箭头添加到sidenave引导程序

时间:2019-04-09 16:02:26

标签: html dropdown sidenav

我是Bootstrap的新手,并且我一直在从事Sidenav的工作。不幸的是,bootstrap网站上的文档并没有太多有关侧面导航的内容。我一直在努力,但我无法让箭头显示在下拉选项上。应该在哪里添加?在一个标签?

<script>$(document).ready(function () {

$('#sidebarCollapse').on('click', function () {
    $('#sidebar').toggleClass('active');
});</script>




     <span style="font-size:20px;cursor:pointer"><button type="button" class=""btn btn-dark" data-toggle="button" aria- 
   pressed="false" autocomplete="off" id="sidebarCollapse">menu</button></span>
   <div class="wrapper">
<!-- Sidebar -->
    <nav id="sidebar">


    <div class="sidebar-header">

    </div>

    <ul class="list-unstyled components">
        <li class="active">
            <a href="#home" data-toggle="collapse" aria-expanded="false">Media</a>
            <ul class="collapse list-unstyled" id="home" data-parent="#sidebar">
                <li>
                    <a href="#">Home 1</a>
                </li>
                <li>
                    <a href="#">Home 2</a>
                </li>
                <li>
                    <a href="#">Home 3</a>
                </li>
            </ul>
        </li>
        <li>

            <a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false">Resources</a>
            <ul class="collapse list-unstyled" id="pageSubmenu" data-parent="#sidebar">
                <li>
                    <a href="#">Page 1</a>
                </li>
                <li>
                    <a href="#">Page 2</a>
                </li>
                <li>
                    <a href="#">Page 3</a>
                </li>
            </ul>

            <a href="#page" data-toggle="collapse" aria-expanded="false"><font color=lightblue>Other</a>
            <ul class="collapse list-unstyled" id="page" data-parent="#sidebar">
                <li>
                    <a href="#">other links</a>
                </li>
                <li>
                    <a href="#">Page 2</a>
                </li>
                <li>
                    <a href="#">Page 3</a>
                </li>
            </ul>
    </ul>
</nav>

1 个答案:

答案 0 :(得分:0)

Bootstrap具有一个可在单击按钮时折叠的属性,您可以使用此

<span style="font-size:20px;cursor:pointer">
	<button type="button" class="btn btn-dark" data-toggle="collapse" aria-pressed="false" autocomplete="off" id="sidebarCollapse" data-target="#collapse1">menu</button></span>
	   <div id = "collapse1" class="wrapper">
			<ul class="list-unstyled components">
			<li class="active">
				<a href="#home" data-toggle="collapse" aria-expanded="false">Media</a>
				<ul class="collapse list-unstyled" id="home" data-parent="#sidebar">
					<li>
						<a href="#">Home 1</a>
					</li>
					<li>
						<a href="#">Home 2</a>
					</li>
					<li>
						<a href="#">Home 3</a>
					</li>
				</ul>
			</li>
			<li>
				<a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false">Resources</a>
				<ul class="collapse list-unstyled" id="pageSubmenu" data-parent="#sidebar">
					<li>
						<a href="#">Page 1</a>
					</li>
					<li>
						<a href="#">Page 2</a>
					</li>
					<li>
						<a href="#">Page 3</a>
					</li>
				</ul>
			</li>
				<a href="#page" data-toggle="collapse" aria-expanded="false"><font color = "lightblue">Other</a>
				<ul class="collapse list-unstyled" id="page" data-parent="#sidebar">
					<li>
						<a href="#">other links</a>
					</li>
					<li>
						<a href="#">Page 2</a>
					</li>
					<li>
						<a href="#">Page 3</a>
					</li>
				</ul>
			</ul>
		</nav>