gpt4 book ai didi

javascript - Bootstrap 导航栏下拉按钮在最小 View 中失败

转载 作者:行者123 更新时间:2023-12-03 09:35:14 25 4
gpt4 key购买 nike

我在导航栏中为管理员显示了一组 Bootstrap (v3.3.4) 按钮。它们的显示和切换非常适合所有接受最小 View 的人。在最小 View 中,它们不再下拉。

HTML 看起来像:

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
<a class="page-scroll" href="#page-top"></a>
</li>
<li>
<a class="page-scroll" href="@Url.MyMvcRoute">Home</a>
</li>
@if (User.Identity.IsAuthenticated)
{
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Admin<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="@Url.MyMvcRoute">Orders</a></li>
<li class="divider"></li>
<li><a href="@Url.MyMvcRoute">Tour Categories</a></li>
<li><a href="@Url.MyMvcRoute">Tours</a></li>
</ul>
</li>
}
</ul>
</div>

enter image description here

最佳答案

零号囚犯,你好。看看这段代码,我使用了您的 admin 导航下拉代码,正如您所看到的,这在此设置中运行良好。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">

<title>Bootstrap Navbar Pull-Down Button fails in smallest view</title>

<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<style>
body {
padding-top: 50px;
}
.spacer {
margin-top: 2%;
margin-bottom: 2%;
}
.block {
height: 400px;
background-color: darkorange;
}
</style>

</head>

<body>


<nav class="navbar navbar-inverse navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand " href="#">Project name</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<!-- @if (User.Identity.IsAuthenticated)
{ -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Admin<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="@Url.MyMvcRoute">Orders</a></li>
<li class="divider"></li>
<li><a href="@Url.MyMvcRoute">Tour Categories</a></li>
<li><a href="@Url.MyMvcRoute">Tours</a></li>
</ul>
</li>
<!-- } -->
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>

<div class="container col-lg-12 spacer"></div>

<div class="container col-lg-12">

<div class="col-xs-10 col-xs-offset-1 block">

</div>

</div><!-- /.container -->

<!-- Bootstrap core JavaScript -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>



</body>
</html>

关于javascript - Bootstrap 导航栏下拉按钮在最小 View 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31358020/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com