簡體   English   中英

導航欄折疊在Bootstrap中無法正常工作

[英]Navbar Collapse not working properly in Bootstrap

這是我的MVC部分視圖:

<nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.RouteLink("მთავარი", "AdminControlUsers", null, new { @class = "navbar-brand", @style="padding-left:100px; padding-right:100px"})//this line
            </div>
    <div class="collapse navbar-collapse" id="myNavbar">
                <ul class="nav navbar-nav">
                    @if (ViewBag.NavBarActive == "მომხმარებლები")
                    {
                        <li class="active">@Html.RouteLink("მომხმარებლები", "AdminControlUsers")</li>
                        <li>@Html.RouteLink("Stored Procedures", "ControlStoredProcedures", new { page = 1 })</li>
                        <li>@Html.RouteLink("გაშვებული Stored Procedure-ები", "Admin_User_Results_List")</li>
                    }
                    @if (ViewBag.NavBarActive == "Stored Procedures")
                    {
                        <li>@Html.RouteLink("მომხმარებლები", "AdminControlUsers")</li>
                        <li class="active">@Html.RouteLink("Stored Procedures", "ControlStoredProcedures", new { page = 1 })</li>
                        <li>@Html.RouteLink("გაშვებული Stored Procedure-ები", "Admin_User_Results_List")</li>
                    }
                    @if (ViewBag.NavBarActive == "User_Admin Results List")
                    {
                        <li>@Html.RouteLink("მომხმარებლები", "AdminControlUsers")</li>
                        <li>@Html.RouteLink("Stored Procedures", "ControlStoredProcedures", new { page = 1 })</li>
                        <li class="active">@Html.RouteLink("გაშვებული Stored Procedure-ები", "Admin_User_Results_List")</li>
                    }
                </ul>
                <ul class="nav navbar-nav navbar-right">
    li><a href='@Url.Action("LogOut", "Administrator")'><span class="glyphicon glyphicon-log-out"></span> გამოსვლა @Session["Admin"].ToString()</a></li>
                </ul>
            </div>
        </div>
    </nav>

調整瀏覽器大小時,我的導航欄屏幕截圖: 在此處輸入圖片說明

在此處輸入圖片說明

在此處輸入圖片說明 在此處輸入圖片說明

當我刪除其中的一行時:

@Html.RouteLink("მთავარი", "AdminControlUsers", null, new { @class = "navbar-brand", @style="padding-left:100px; padding-right:100px"})

如果我刪除@ style =“ padding-left:100px; padding-right:100px”,則它會正常工作:/。 請幫忙

內容比合攏button快溢出,您需要將導航欄合攏按鈕設置為更早顯示。

您可以通過CSS進行設置,最后在樣式表中進行設置(根據需要調整min-widthmax-width ):

@media (min-width: 768px) and (max-width: 991px) {
    .navbar-collapse.collapse {
        display: none !important;
    }
    .navbar-collapse.collapse.in {
        display: block !important;
    }
    .navbar-header .collapse, .navbar-toggle {
        display:block !important;
    }
    .navbar-header {
        float:none;
    }
}

在可調整大小的外部Fiddle上進行測試

在此處輸入圖片說明

這個給你:

 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Case</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <nav id="menu" class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a> </li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Page 1-1</a> </li> <li><a href="#">Page 1-2</a> </li> <li><a href="#">Page 1-3</a> </li> </ul> </li> <li><a href="#">Page 2</a> </li> <li><a href="#">Page 3</a> </li> </ul> </div> </div> </nav> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> <p>abc</p> </body> </html> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM