为什么不显示导航栏项?

时间:2016-06-25 07:53:20

标签: css twitter-bootstrap css3 navbar nav

我有以下代码,除了Mona Jalal和右上角旁边的白色小按钮,没有其他显示:

<div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav-main">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index.html">Mona Jalal</a>
            </div>

            <div class="collapse navbar-collapse" id="nav-main">
                <ul class="nav navbar-nav">
                    <li><a class="nav-item nav-link active page-item" href="index.html">Mona Jalal <span class="sr-only">(current)</span></a></li>
                    <li><a class="nav-item nav-link page-item" href="education.html">Education</a></li>
                    <li><a class="nav-item nav-link page-item" href="coursework.html">Coursework</a></li>
                    <li><a class="nav-item nav-link page-item" href="teaching.html">Teaching</a></li>
                    <li><a class="nav-item nav-link page-item" href="projects.html">Projects</a></li>
                    <li><a class="nav-item nav-link page-item" href="honors.html">Honors & Awards</a></li>
                    <li><a class="nav-item nav-link page-item" href="experience.html">Experience</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">

                    <li><a class="navbar-brand pull-sm-right" href="https://github.com/monajalal"><i class="fa fa-github fa-lg"></i></a></li>
                    <li><a class="navbar-brand pull-sm-right" href="https://twitter.com/MonaJalal_"><i class="fa fa-twitter fa-lg"></i></a></li>
                    <li><a class="navbar-brand pull-sm-right" href="https://www.linkedin.com/in/mona-jalal"><i class="fa fa-linkedin fa-lg"></i></a></li>
                    <li><a class="navbar-brand pull-sm-right" href="http://stackoverflow.com/users/2414957/mona-jalal"><i class="fa fa-stack-overflow fa-lg"></i></a></li>
                    <li><a class="navbar-brand pull-sm-right" href="mailto:jalal@cs.wisc.edu"><i class="fa fa-envelope fa-lg" aria-hidden="true"></i></a></li>
                    <li><a class="navbar-brand pull-sm-right" href="https://www.instagram.com/mona_of_green_gables"><i class="fa fa-instagram fa-lg"></i></a></li>

                </ul>
            </div>
        </div>

enter image description here 我首先得到了以下代码,但是当我将屏幕宽度变得更小时,事情变得奇怪了,所以我决定使用一个按钮,如果你点击它就会显示项目(比如在手机中或说你看到的按钮)在Chrome的右侧角落有三条线)。以下代码实际上有效,但我说的有这个问题。我有点失落所以,如果你能给我一些提示,那将会很棒:)

<div class="container">
    <nav class="navbar navbar-dark bg-primary navbar-fixed-top">
        <div class="nav navbar-nav">
            <a class="nav-item nav-link page-item" href="index.html">Mona Jalal <span class="sr-only">(current)</span></a>
            <a class="nav-item nav-link active page-item" href="education.html">Education</a>
            <a class="nav-item nav-link page-item" href="coursework.html">Coursework</a>
            <a class="nav-item nav-link page-item" href="teaching.html">Teaching</a>
            <a class="nav-item nav-link page-item" href="projects.html">Projects</a>
            <a class="nav-item nav-link page-item" href="honors.html">Honors & Awards</a>
            <a class="nav-item nav-link page-item" href="experience.html">Experience</a>
            <a class="navbar-brand pull-sm-right m-r-0" href="https://github.com/monajalal"><i class="fa fa-github fa-lg"></i></a>
            <a class="navbar-brand pull-sm-right m-r-2" href="https://twitter.com/MonaJalal_"><i class="fa fa-twitter fa-lg"></i></a>
            <a class="navbar-brand pull-sm-right m-r-4" href="https://www.linkedin.com/in/mona-jalal"><i class="fa fa-linkedin fa-lg"></i></a>
            <a class="navbar-brand pull-sm-right m-r-6" href="http://stackoverflow.com/users/2414957/mona-jalal"><i class="fa fa-stack-overflow fa-lg"></i></a>
            <a class="navbar-brand pull-sm-right m-r-8" href="mailto:jalal@cs.wisc.edu"><i class="fa fa-envelope fa-lg" aria-hidden="true"></i></a>
            <a class="navbar-brand pull-sm-right m-r-10" href="https://www.instagram.com/mona_of_green_gables"><i class="fa fa-instagram fa-lg"></i></a>
        </div>
    </nav>
</div>

enter image description here

如果您需要更多详细信息或问题不够明确,请与我们联系。

更新:第二个例子正在运行,问题是当我减小屏幕的宽度时恰好是这样的,因为我是bootstrap / CSS的新手,我不确定什么是正确的术语描述问题,但我想照片显示最好! enter image description here

1 个答案:

答案 0 :(得分:1)

这可能是由于“折叠导航栏崩溃”造成的。 CSS类适用于&#39; nav-main&#39; DIV。查看bootstrap文档,看看是否有任何关于默认导航栏(http://getbootstrap.com/components/#navbar-default)的重要说明适用于您的情况。