gpt4 book ai didi

javascript - Bootstrap - 折叠的菜单项水平显示而不是垂直显示

转载 作者:行者123 更新时间:2023-11-28 04:34:23 26 4
gpt4 key购买 nike

出于某种原因,无论我做什么,我的导航栏都会在折叠时水平显示菜单项,并在它们中间显示我的 Logo !当我使用 visible-xs 等时,它在可见时出于某种原因将其向左对齐!

我尝试过在其他类似溢出问题上找到的方法,例如显示列表项 inline-block(尽管不想使用 inline-styles!)

但是没有什么对我有用!

我知道问题是因为我的 Logo 位于桌面 View 中菜单项的中央,所以它不是标准菜单,但必须有一种方法可以使我的菜单项垂直显示而没有 Logo 在中间?我对此很陌生,所以也许我只是愚蠢而遗漏了什么?

如果有任何不同,我正在使用 jquery mobile(这会破坏菜单并阻止它被关闭吗?)

这是我已经尝试过的:

导航栏的 HTML:

<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, no-index">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags must come first in the head; any other head content must come after these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favv.ico">


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>

<script type="text/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>

<script src="../assets/js/main.js"></script>



<!-- Custom styles for this template -->
<link href="../node_modules/jquery-mobile/mobilestyles.css" rel="stylesheet">
<link href="/Silver-Lining/css/template.css" rel="stylesheet">



<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet">


<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>


<![endif]>






<!--============ Navigation ===============-->



<nav class="navbar navbar-default navbar-fixed-top text-center">


<nav id="navbar-primary" class="navbar" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<div class="top-social">
<a href="tel:+1-303-499-7111"> <i class="fa fa-phone" aria-hidden="true">
</i> 0787000000
</a>

<a href="#">
<i class="fa fa-facebook-official" aria-hidden="true"></i>
</a>
<a href="#">
<i class="fa fa-twitter-square" aria-hidden="true"></i>
</a>

<a href="#">
<i class="fa fa-instagram" aria-hidden="true"></i>
</a>

<a href="#">
<i class="fa fa-linkedin-square" aria-hidden="true"></i>
</a>

</div>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar-primary-collapse">
<ul class="nav navbar-nav">
<li><a href="about-us.php" data-ajax="false">ABOUT</a></li>
<li><a href="gallery.php" data-ajax="false">OUR CARS</a></li>
<li><a href="Prices.php" data-ajax="false">PRICES</a></li>
<a class="hidden-sm-down" href="index.php" data-ajax="false"><img src="../assets/images/logo" width="250" alt="Logo"></a>
<li><a href="#" data-ajax="false">PACKAGES</a></li>
<li><a href="gallery.php" data-ajax="false">BLOG</a></li>
<li><a href="contact.php" data-ajax="false">CONTACT</a></li>

</ul>
</div>
<!-- /.navbar-collapse -->

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

使菜单项在折叠时垂直显示的 CSS 示例:

 @media (max-width: 932px) {
#navbar-primary .navbar-nav li a {
float: none;
position: inherit;
display: inline-block !important;
vertical-align: top;
max-height: 300px;
}
}

导航栏的CSS

// Remove excess borders
.navbar-default {
border-top: none;
border-left: 0;
border-right: none;
margin-top: 0px;
padding-bottom: 10px;
font-family: 'Open Sans Condensed', sans-serif;
margin-bottom: 0;
font-size: 18px;
border-color: transparent;
white-space: normal;
}

.navbar-default .navbar-nav > li {
margin-top: 20px;
}

任何帮助将不胜感激,我一直很困惑,至少坚持了好几天,真的很想保留相同的导航栏而不必重新做一遍

最佳答案

经过大量代码我发现

@media screen and (max-width: 768px) {
#navbar-primary .navbar-nav > li {
display: block;
}
}

给我想要的结果(折叠时垂直堆叠的菜单项!)

关于javascript - Bootstrap - 折叠的菜单项水平显示而不是垂直显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41560760/

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