gpt4 book ai didi

html - 使导航折叠

转载 作者:行者123 更新时间:2023-11-28 06:36:13 25 4
gpt4 key购买 nike

这是来自 Bootstrap 网站的导航栏,以及 css。我怎样才能让它在低于 768px 时折叠?我想要一个合理的导航并尝试查看具有折叠功能的导航,但不确定在哪里添加它。任何帮助,将不胜感激。谢谢,jodmcc

HTML

  <!-- The justified navigation menu is meant for single line per list item.
Multiple lines will require custom code not provided by Bootstrap. -->
<div class="masthead">
<h3 class="text-muted">Project name</h3>
<nav>
<ul class="nav nav-justified">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>

CSS

   .nav-justified {
background-color: #eee;
border: 1px solid #ccc;
border-radius: 5px;
}
.nav-justified > li > a {
padding-top: 15px;
padding-bottom: 15px;
margin-bottom: 0;
font-weight: bold;
color: #777;
text-align: center;
background-color: #e5e5e5; /* Old browsers */
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e5e5e5));
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
background-image: linear-gradient(to bottom, #f5f5f5 0%,#e5e5e5 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background-repeat: repeat-x; /* Repeat the gradient */
border-bottom: 1px solid #d5d5d5;
}
.nav-justified > .active > a,
.nav-justified > .active > a:hover,
.nav-justified > .active > a:focus {
background-color: #ddd;
background-image: none;
-webkit-box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified > li:first-child > a {
border-radius: 5px 5px 0 0;
}
.nav-justified > li:last-child > a {
border-bottom: 0;
border-radius: 0 0 5px 5px;
}

最佳答案

您可以在应隐藏在 768px 以下的元素上使用 Bootstrap 的 .hidden-xs CSS 类。相反,您可以使用 .visible-xs-block.visible-xs-inline.visible-xs 使元素仅出现在 768px 或更高像素以上-inline-block(取决于您的显示样式)。

例如,您可以尝试:

<div class="hidden-xs">
Standard menu code, visible at 768px or above
</div>
<div class="visible-xs-block">
Collapsed menu code, only visible below 768px
</div>

关于html - 使导航折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34669412/

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