Html 引导3-带下拉菜单的导航栏,下拉菜单的扩展超出最大高度

Html 引导3-带下拉菜单的导航栏,下拉菜单的扩展超出最大高度,html,css,twitter-bootstrap-3,Html,Css,Twitter Bootstrap 3,我试图在导航栏折叠中使用下拉菜单。问题是,当我不打开下拉列表时,一切正常,这意味着我不需要滚动条来查看内容。但是,当切换下拉列表时,高度不会改变,因此下拉列表的内容不可见 如果我不打开下拉列表: 一切都很好,但当我打开下拉菜单时:我丢失了3个只能滚动的菜单,它们是:添加、编辑、删除 您需要上下滚动 这是我的CSS代码: /* * Base structure */ /* Move down content because we have a fixed navbar that is 5

我试图在导航栏折叠中使用下拉菜单。问题是,当我不打开下拉列表时,一切正常,这意味着我不需要滚动条来查看内容。但是,当切换下拉列表时,高度不会改变,因此下拉列表的内容不可见

如果我不打开下拉列表:

一切都很好,但当我打开下拉菜单时:我丢失了3个只能滚动的菜单,它们是:添加、编辑、删除

您需要上下滚动

这是我的CSS代码:

/*
 * Base structure
 */

/* Move down content because we have a fixed navbar that is 50px tall */
body 
{
    overflow-y: scroll;
}

/*
 * Global add-ons
 */

.custom-button-length
{
    width: 100px;
}

.sub-header 
{
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/*
 * Top navigation
 * Hide default border to remove 1px line.
 */
@media (max-width: 767px) 
{
    .navbar-fixed-top
    {
        position: relative;
        top: auto;
    }

    .navbar-collapse 
    {
        max-height: none;
    }

    body 
    {
        margin: 0;
    }

    .navbar-default 
    {
        max-height: none;
    }
}

/*
 * Sidebar
 */

/* Hide for mobile, show later */
.wrapper 
{
    padding-left: 0;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

.wrapper.toggled 
{
    padding-left: 250px;
}

.wrapper.toggled .sidebar 
{
    width: 0px;
    padding-left: 0px;
    padding: 0px;
}

.sidebar 
{
    position: fixed;
    top: 51px;
    bottom: 0;
    left: 0px;
    z-index: 1000;
    display: block;
    padding: 20px;
    padding-right: 100px;
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
    background-color: #f5f5f5;
    border-right: 1px solid #eee;
    -webkit-transition: all 1.0s ease;
    -moz-transition: all 1.0s ease;
    -o-transition: all 1.0s ease;
    transition: all 1.0s ease;
}

@media (max-width: 768px) 
{
    .sidebar 
    {
        width: 0px;
        padding-left: 0px;
        padding: 0px;
    }
}

/* Sidebar navigation */
.nav-sidebar 
{
    margin-right: -21px; /* 20px padding + 1px border */
    margin-bottom: 20px;
    margin-left: -20px;
}

.nav-sidebar > li > a 
{
    padding-right: 20px;
    padding-left: 20px;
    position: fixed-top;
}

.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus 
{
    color: #fff;
    background-color: #428bca;
}


/*
 * Main content
 */

.main 
{
    padding: 20px;
    margin-left: 210px;
    margin-top:50px;
    -webkit-transition: all 1.0s ease;
    -moz-transition: all 1.0s ease;
    -o-transition: all 1.0s ease;
    transition: all 1.0s ease;
}

@media (max-width: 768px) 
{
    .main 
    {
        margin-left: 0px;
        margin-top: -20px;
        padding-top: 20px;
        -webkit-transition: all 1.0s ease;
        -moz-transition: all 1.0s ease;
        -o-transition: all 1.0s ease;
        transition: all 1.0s ease;
    }
}

.main .page-header 
{
    margin-top: 0;
}

.main.toggled
{
    padding: 20px;
    margin-left: 0px;
    -webkit-transition: all 1.0s ease;
    -moz-transition: all 1.0s ease;
    -o-transition: all 1.0s ease;
    transition: all 1.0s ease;
}

/*
 * Placeholder dashboard ideas
 */

.placeholders 
{
    margin-bottom: 30px;
    text-align: center;
}
.placeholders h4 
{
    margin-bottom: 0;
}
.placeholder 
{
    margin-bottom: 20px;
}
.placeholder img 
{
    display: inline-block;
    border-radius: 50%;
}

.graph-container
{
    box-sizing: border-box;
    width: 850px;
    height: 450px;
    padding: 20px 15px 15px 15px;
    margin: 15px auto 30px auto;
    border: 1px solid #ddd;
    background: #fff;
    background: linear-gradient(#f6f6f6 0, #fff 50px);
    background: -o-linear-gradient(#f6f6f6 0, #fff 50px);
    background: -ms-linear-gradient(#f6f6f6 0, #fff 50px);
    background: -moz-linear-gradient(#f6f6f6 0, #fff 50px);
    background: -webkit-linear-gradient(#f6f6f6 0, #fff 50px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    -o-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    -ms-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    -webkit-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.graph-placeholder 
{
    width: 100%;
    height: 100%;
    font-size: 14px;
    line-height: 1.2em;
}

.legend table
{
    border-spacing: 5px;
}
这是我的HTML代码:

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <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>
            <a class="navbar-brand" href="#"> WebStats</a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Dashboard</a></li>
                <li><a href="#">Settings</a></li>
                <li><a href="#">Profile</a></li>
                <li><a href="{% url 'WebApp:logout'%}">Logout</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-left">
                <li><a href="{% url 'WebApp:index'%}">Views</a></li>

                <li><a href="#toggleMenu">SideBar</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        Chart Options
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" role="menu" data-no-collapse="true">
                        <li><a href="{% url 'WebApp:addChart'%}">Add</a></li>
                        <li><a href="{% url 'WebApp:editChart'%}">Edit</a></li>
                        <li><a href="#removeChart">Remove</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>

切换导航

在移动模式下,当像素小于768时,我将“最大高度”应用于“无”,但是,它仍然需要向下滚动。

在移动媒体查询中的
最大高度
属性中添加
重要声明:

.navbar-collapse {
    max-height: none!important;
}

首先,没有必要为移动设备定义自己的css。推特引导首先是移动的,你只需要遵循这一点

希望它能帮助