垂直对齐标题中的内容

时间:2018-03-16 01:48:54

标签: bootstrap-4

您好我想在我的网站上完成一些工作,我第一次使用bootstrap 4而且我遇到了一些困难。

这是我的代码:

<header class="header container-fluid">
    <div class="row justify-content-between d-flex flex-row align-items-center">

        <img class="logo" src="./images/logo.png" alt="Example Company" title="Example Company" />

        <ul class="menu align-self-center">
            <li><a href="{{ url("home") }}">Home</a></li>
            <li><a href="{{ url("home") }}">About us</a></li>
            <li><a href="{{ url("home") }}">How it works</a></li>
            <li><a href="{{ url("home") }}">Contact us</a></li>
        </ul>

    </div>
</header>

现在我希望徽标在左侧对齐菜单链接以与右侧对齐,但两者都应垂直居中,如下所示:

enter image description here

1 个答案:

答案 0 :(得分:2)

检查所有对齐

<nav class="navbar navbar-expand-md navbar-dark bg-dark">
    <div class="navbar-collapse collapse w-100 order-1 order-md-0 dual-collapse2">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#">Left</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="//codeply.com">Codeply</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
        </ul>
    </div>
    <div class="mx-auto order-0">
        <a class="navbar-brand mx-auto" href="#">Navbar 2</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".dual-collapse2">
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
    <div class="navbar-collapse collapse w-100 order-3 dual-collapse2">
        <ul class="navbar-nav ml-auto">
            <li class="nav-item">
                <a class="nav-link" href="#">Right</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
        </ul>
    </div>
</nav>