gpt4 book ai didi

css - 平板电脑的 Bootstrap 移动菜单?

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

我正在尝试更改我的代码,以便在移动设备和平板电脑上折叠导航,但我似乎无法让它工作。我尝试将 @grid-float-breakpoint 更改为 992px 但这似乎不起作用。关于我可能哪里出错的任何想法?

我简化了 html,因为它太多了,但我想你会明白的。

<div id="main-nav" class="row">
<div class="header-wrap">
<div class="site-branding">
<p class="site-title"><a href="#" rel="home">SITE TITLE</a></p>
</div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
<ul id="primary-menu" class="menu">
<li class="menu-item menu-item-has-children dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" href="#">Parent Link<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li class="menu-item"><a href="#">Sub Link</a></li>
<li class="menu-item"><a href="#">Sublink</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>

SCSS

.nav-menu {
display: none;
position: relative;
top: 70px;
}
.dropdown-menu {
display: none;
position: static;
width: 100%;
li {
width: 100%;
}
}

.main-navigation.toggled {
.nav-menu {
width: 100%;
display: block;
background-color: #363636;
li {width: 100%; display: block;background-color: #363636; text-transform: uppercase; border-top: .5px solid #434343;}
li > a {
padding: 8px;
pointer-events: none; // prevent it's immediate A child to follow HREF
cursor: default;
}
a {color: #fff;}
.dropdown-menu {
position:static;
top: 80px;
display: none;
background: none;
box-shadow: none;
padding: 0;
a {
color: #fff;
pointer-events: auto;
cursor: pointer;
}
li {
background-color: #000;
a {
width: 100%;
&:hover {
color: #000;
}
}
}
}
}
}

@media (min-width: 992px) {
#masthead:hover {
padding-top:29px;
background-color:$site-dark-gray;
-webkit-box-shadow:0 0 8px rgba(0, 0, 0, 0.7);
-moz-box-shadow:0 0 8px rgba(0, 0, 0, 0.7);
box-shadow:0 0 8px rgba(0, 0, 0, 0.7);
height:100px;
.site-branding{
width:240px;
height:49px;
@media (max-width: $screen-sm-max) {
width:210px;
}
.site-title{
a{
width:167px;
height:49px;
}
}
}
@media (max-width: $screen-xs-max) {
padding-top:29px;
height:100px;
}
}
.main-navigation {
.nav-menu {
top: 0;
}
.dropdown-menu {
visibility: hidden;
display: block;
opacity: 0;
border-radius: 0;
top: 3.15em;
background-color: $site-dark-gray;
// transform: translateY(-20px);
transform: translateY(20px);
transition: all .3s ease;
left: -1.5em !important;
overflow: hidden;
padding: 0;
border: 0;
li:first-child {display: none !important;}
li {
margin: 0 !important;
transition: all .3s ease;
a {
padding-top: 8px;
padding-bottom: 8px;
}
&:hover a {
color: #000 !important;
background-color: #fff;
}
}
.active > a {
background-color: #fff;
color: #000 !important;
}
}

.dropdown:hover .dropdown-menu {
display: block;
opacity: 1;
visibility: visible;
transform: translateY(0px);
}
.dropdown:after {
content: "";
display: block;
height: 2em;
position: absolute;
top: 1em;
width: 100%;
}
}
}

最佳答案

我认为这可能是因为您缺少 data-toggle="collapse"data-target="#primary-menu" 属性从您的导航切换按钮,因为这就是告诉菜单它是否应该处于事件状态的原因。在 example on Bootstrap's website 中查看他们的处理方式.

关于css - 平板电脑的 Bootstrap 移动菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42816403/

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