导航栏连续对齐项目

时间:2017-12-11 15:35:31

标签: html bootstrap-4

我正在尝试让我的导航栏项目对齐而不是堆叠。我从bootstrap 3切换到4(beta 2),由于某种原因,它不再很好地对齐,但仍然堆叠。这是我的代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>index__</title>
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet" type="text/css">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">

</head>




<body>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>



    <nav class="navbar fixed-top">
        <div class="container">
            <span class="pull-left">
            <a href="#" class="navbar-brand">
            <img src="img/gyn_sm.png" alt="">
            </a>
            </span>

            <ul class="nav navbar-nav ml-auto">
                <li>one</li>
                <li>two</li>
            </ul>
        </div>  
    </nav>




</body>
</html>

1 个答案:

答案 0 :(得分:1)

请查看此pdated JSFiddle以获得答案。您的.navbar-nav获得了display: flex;,但没有获得方向。将其添加到CSS中:

.navbar-nav {
  flex-direction: row;
}

会修复它。详细了解flex-direction on MDN