导航栏上方的Bootstrap 4页宽标题栏

时间:2018-02-09 10:20:51

标签: css twitter-bootstrap bootstrap-4

我有一个工作的导航栏,但是如何在导航栏(Pagewide div)上方获得一个页面宽度栏。在移动视图中,栏可以消失。

<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark">
            <div>
                Pagewide
            </div>
            <div class="container" style="padding: 0px;">
                <a class="navbar-brand" href="<?php echo $this->url('home'); ?>" target="_self">
                    <img src="<?= $this->basePath('img/logo.png') ?>" style="width: 100%;"/>
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <form class="form-inline my-2 my-lg-0">
                    <input class="form-control form-control-sm mr-sm-2" type="search" placeholder="Search">
                    <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
                </form>
                <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item active">
                            <a class="nav-link" href="<?= $this->basePath('inloggen') ?>">Inloggen<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>
                </div>   
            </div>
        </nav>

1 个答案:

答案 0 :(得分:1)

固定顶部导航栏始终位于顶部。

要将标题栏放在其上方,请确定您希望页面宽度栏的高度,并在固定导航栏上方设置top:空格。使用媒体查询隐藏在较小的屏幕上。

https://www.codeply.com/go/bembG1Lulg

@media (min-width: 992px) {
    .navbar {
        top: 54px;
    } 

    .pagewide {
        height: 54px;
    }
}