Bootstrap中导航栏崩溃

时间:2016-02-24 22:19:52

标签: html css twitter-bootstrap-3 collapse

我正在制作基于bootstrap的新网站,但每当我点击按钮navbar-collapsed它崩溃时,我也希望得到它应该在的位置(在导航栏的底部)和折叠按钮在徽标的中间,但我无法弄清楚collapse not working properly

HTML

<!-- Navigation -->
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Zobrazit navigaci</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index.html"><img src="logo.png" width="50px" height="50px"></a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Škola <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="portfolio-1-col.html">Výroční zprávy</a>
                            </li>
                            <li>
                                <a href="portfolio-2-col.html">Zaměstnanci</a>
                            </li>
                            <li>
                                <a href="portfolio-3-col.html">Historie</a>
                            </li>
                            <li>
                                <a href="portfolio-4-col.html">Kompletní informace</a>
                            </li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Studium <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="portfolio-1-col.html">Informační technologie</a>
                            </li>
                            <li>
                                <a href="portfolio-2-col.html">Agropodnikání</a>
                            </li>
                            <li>
                                <a href="portfolio-3-col.html">Obchodní akademie</a>
                            </li>
                            <li>
                                <a href="portfolio-4-col.html">Maturity</a>
                            </li>
                            <li>
                                <a href="portfolio-item.html">Formuláře</a>
                            </li>
                            <li>
                                <a href="xxx.html">Třídy</a>
                            </li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Jídelna <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="blog-home-1.html">Jídelníček</a>
                            </li>
                            <li>
                                <a href="blog-home-2.html">Přihlašování obědů</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="#">Domov mládeže </a>
                    </li>
                     <li>
                        <a href="#">Galerie </a>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

CSS

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
html,
body {
    height: 100%;
    font-family: 'Open Sans', sans-serif;
}

.navbar-fixed-top {
background-color: #5b5147;
    border-color: transparent;
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    height: 100px;
    text-transform: uppercase;
}


.navbar-inverse li {
padding-top: 20px;

}

.navbar-brand {
padding-top: 20px;
}

body {
    padding-top: 100px; /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
}

.img-portfolio {
    margin-bottom: 30px;
}

.img-hover:hover {
    opacity: 0.8;
}

/* Home Page Carousel */

header.carousel {
    height: 500px;
}

header.carousel .item,
header.carousel .item.active,
header.carousel .carousel-inner {
    height: 100%;
}

header.carousel .fill {
    width: 100%;
    height: 100%;
    background-position: center;
    background-size: cover;
}

.center-block {
float:none;
    display: inline-block;
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    text-align: center;
}

#ikonky{
color: #5c6465;
}



/* Footer Styles */

footer {
    margin: 50px 0;
}

/* Responsive Styles */

@media(max-width:767px) {
    .img-portfolio {
        margin-bottom: 15px;
    }

    header.carousel .carousel {
        height: 70%;
    }

}

1 个答案:

答案 0 :(得分:0)

如果你改变了这个

.navbar-fixed-top {
    height: 100px;
}

到此:

.navbar-fixed-top {
    min-height: 100px;
}

背景颜色应在菜单打开时显示。