Bootstrap 4导航栏定位

时间:2017-11-06 07:26:09

标签: html css twitter-bootstrap bootstrap-4

我似乎无法弄清楚如何将导航栏的位置设置到某些位置。我希望品牌名称,即#34; Athletics",留在左边,其他选项留在左边。我尝试了#34; navbar-left"," navbar-right",网格系统和一些CSS,但似乎没有任何效果。以下是我的代码的链接:https://jsfiddle.net/mcoulibaly23/9sn2kx58/ 我也会在下面发布:

<htnl>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <title>Navbar | Athletics </title>       
</head>
<body>

    <nav class= "navbar navbar-expand-lg fixed-top navbar-dark" style="background-color:darkmagenta; font-family:Roboto;">
        <a class="navbar navbar-brand" href="#"> Athletics </a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
            <ul class="navbar-nav">

                <li class="active"><a class="nav-item nav-link" href="#"> Shop </a></li>
                <li><a class="nav-item nav-link" href="#"> About Us </a></li>
                <li><a class="nav-item nav-link" href="#"> Lookbook </a></li>
                <li><form class="form-inline">
                    <input class="form-control mr-sm-2" type="search" placeholder="Search" height="10">
                    <button class="btn bth-outline-success" type="Submit"> Search </button>
                </form></li>
            </ul>
        </div>
   </nav>
</body>

1 个答案:

答案 0 :(得分:0)

如果我说得对,你想在左边有品牌名称,在导航栏上有导航项目吗? 如果是,那么这个类应该做“proty-content-end”技巧

我已经稍微修改了你的代码,并对我在哪里做了更正进行了评论:

<!-- appropriate for html5 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <title>Navbar | Athletics </title>       
</head>
<body>

    <nav class= "navbar navbar-expand-lg fixed-top navbar-dark" style="background-color:darkmagenta; font-family:Roboto;">
        <a class="navbar navbar-brand" href="#"> Athletics </a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
        </button>

        <!-- add class justify-content-end to the div below to have nav-items positioned on right --> 
        <div class="collapse navbar-collapse justify-content-end" id="navbarNavAltMarkup">
            <ul class="navbar-nav">

                <li class="active"><a class="nav-item nav-link" href="#"> Shop </a></li>
                <li><a class="nav-item nav-link" href="#"> About Us </a></li>
                <li><a class="nav-item nav-link" href="#"> Lookbook </a></li>
                <li><form class="form-inline">
                    <input class="form-control mr-sm-2" type="search" placeholder="Search" height="10">
                    <button class="btn bth-outline-success" type="Submit"> Search </button>
                </form></li>

            </ul>


        </div>

    </nav>


</body>