bootstrap导航栏垂直显示而不是水平显示

bootstrap导航栏垂直显示而不是水平显示

本文介绍了bootstrap导航栏垂直显示而不是水平显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的页面上 navbar 垂直显示,而不是水平显示。

On my page navbar appears vertically instead of horizontally.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>
            Home | Bootstrap
        </title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
    </head>
    <body>
        <nav class="navbar navbar-light bg-faded">
            <a class="navbar-brand" href="#">My bootstrap application</a>
            <ul class="nav navbar-nav">
                <li class="nav-item active">
                    <a class="nav-link" href="index.html">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="about.html">About</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="contact.html">Contact</a>
                </li>
            </ul>
            <form class="form-inline pull-xs-right">
                <input class="form-control" type="text" placeholder="Search" />
                <button class="btn btn-primary" type="submit">Search</button>
            </form>
        </nav>
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <h1>hello world!</h1>
                </div>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    Bootstrap 4
                </div>
            </div>
        </div>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
    </body>
</html>

这是为什么?根据文档,它应该是水平的默认值。

Why is that? According to the docs it should horizontal by default.

推荐答案

添加 navbar-toggleable-md class nav 元素使它在 md 视图中水平显示:

Add navbar-toggleable-md class in nav element to make it looks horizontally in md view :

Docs :

这篇关于bootstrap导航栏垂直显示而不是水平显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:01