移动设备上未显示导航栏

Navbar is not showing up on mobile(移动设备上未显示导航栏)

本文介绍了移动设备上未显示导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <!-- Navbar -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        
        <div class="container-fluid">
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link active" aria-current="page" href="index.html">Home</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="`enter code here`">Resume</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="">Linkedin</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="">GitHub</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="">Email</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

这是用bootstrap制作的html格式的导航栏。但不知何故,它并没有显示在手机上,有什么建议可以改变这一点吗?我试了很多,我也看了前面的问题,但都没有用

推荐答案

如Bootstrap 5 docs...

导航栏可以使用.navbar-toggler、.navbar-坍塌和 .navbar-展开{-sm|-md|-lg|-xl|-xxl}类以确定其 内容折叠在按钮后面&Quot;

您的代码缺少切换器...

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container-fluid">
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="index.html">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="`enter code here`">Resume</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="">Linkedin</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="">GitHub</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="">Email</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

Demo


还请注意data attributes have changed in Bootstrap 5

这篇关于移动设备上未显示导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:移动设备上未显示导航栏

基础教程推荐