移动设备上未显示汉堡菜单
Hamburger Menu not showing on mobile devices
我正在使用 bootstrap 3.4.x,但出于某种原因,我的菜单在移动设备上不可见。我可以在浏览器中调整大小,一切都很好,但在设备上看什么都没有。视口设置在 head 标签中,jquery 在 bootstrap 之前加载。我一辈子都找不到问题所在。 ???下面是想要的结果(站点:site in question)
这是手机的样子:
Menu is missing
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#ham-menu">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/">LOGO Here</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav" id="ham-menu">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/Schedule">Schedule</a></li>
<li><a runat="server" href="~/Gallery">Gallery</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
</ul>
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register">Register</a></li>
<li><a runat="server" href="~/Account/Login">Log in</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li>
<a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName() %>!</a>
</li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>
</body>
</html>
更新:我查看了您提供的相关网站link。似乎一切都很好。现在你只需要移动 id="ham-menu"
属性。
因此,我将您的代码复制并粘贴到 bootstrap 3.4.x 已正确初始化的页面上。原来你的 HTML 代码没有问题,只有一个问题:
将 id 属性从 <ul>
移到外部 <div>
。
<div class="navbar-collapse collapse" id="ham-menu"><!--To Here-->
<ul class="nav navbar-nav"><!--From Here-->
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/Schedule">Schedule</a></li>
<li><a runat="server" href="~/Gallery">Gallery</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
</ul>
</div>
现在,请确保您已正确初始化 bootstrap。要点:
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
我发现这篇文章有效。请务必注意底部的 Olorunfemi Ajibulu 评论。正在重新分级,删除目标位置的其他文件!!
Disable aspnet.friendlyurl's mobile redirect for tablets
我正在使用 bootstrap 3.4.x,但出于某种原因,我的菜单在移动设备上不可见。我可以在浏览器中调整大小,一切都很好,但在设备上看什么都没有。视口设置在 head 标签中,jquery 在 bootstrap 之前加载。我一辈子都找不到问题所在。 ???下面是想要的结果(站点:site in question)
这是手机的样子:
Menu is missing
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#ham-menu">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/">LOGO Here</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav" id="ham-menu">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/Schedule">Schedule</a></li>
<li><a runat="server" href="~/Gallery">Gallery</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
</ul>
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register">Register</a></li>
<li><a runat="server" href="~/Account/Login">Log in</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li>
<a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName() %>!</a>
</li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>
</body>
</html>
更新:我查看了您提供的相关网站link。似乎一切都很好。现在你只需要移动 id="ham-menu"
属性。
因此,我将您的代码复制并粘贴到 bootstrap 3.4.x 已正确初始化的页面上。原来你的 HTML 代码没有问题,只有一个问题:
将 id 属性从 <ul>
移到外部 <div>
。
<div class="navbar-collapse collapse" id="ham-menu"><!--To Here-->
<ul class="nav navbar-nav"><!--From Here-->
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/Schedule">Schedule</a></li>
<li><a runat="server" href="~/Gallery">Gallery</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
</ul>
</div>
现在,请确保您已正确初始化 bootstrap。要点:
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
我发现这篇文章有效。请务必注意底部的 Olorunfemi Ajibulu 评论。正在重新分级,删除目标位置的其他文件!!
Disable aspnet.friendlyurl's mobile redirect for tablets