Navbar没有使用Bootstrap 4的风格

时间:2018-03-08 04:01:15

标签: php html css wordpress

我的导航栏不应用任何样式,甚至不应用默认值:
Navbar collapsed

Navbar expanded

在头上:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

身体:

<body <?php body_class($twichies_classes); ?>

<div class="container-fluid">

        <div class="row">

            <div class="col-xl-12">

                <nav class="navbar navbar-expand-lg navbar-fixed-top navbar-dark danger-color">
                    <div class="container-fluid">
                        <div class="navbar-header">
                            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                            </button>
                            <a class="navbar-brand" href="#">
                                My Theme
                            </a>
                        </div>
                        <div class="collapse navbar-collapse" id="navbarNav">
                            <?php 
                                wp_nav_menu(array(
                                    'theme_location' => 'primary',
                                    'container' => false,
                                    'menu_class' => 'nav navbar-nav navbar-right'
                                    )
                                );
                            ?>
                            <form class="form-inline my-2 my-lg-0">
                                <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
                                <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
                            </form>
                        </div>
                    </div><!-- /.container-fluid -->
                </nav>

            </div>

        </div>
    </div>

最后:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

已尝试过不同的课程设置,例如更改为默认值,但它只更改“我的主题”的颜色。似乎wp_nav_menu项目让它看起来很奇怪..任何想法?谢谢你的帮助! :)

1 个答案:

答案 0 :(得分:0)

Image 1

当点击菜单时屏幕很小时,它将显示以下图像。

Imge 2

这是导航栏的图像。

在你的代码中我改变了

:此

<nav class="navbar navbar-expand-lg navbar-fixed-top navbar-dark danger-color">

<nav class="navbar navbar-expand-lg fixed-top navbar-dark danger-color" style="background: #000;">

此行之后的php代码

<div class="collapse navbar-collapse" id="navbarNav">

    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>

我在这里没有使用任何CSS。