本文介绍了导航栏上方的Bootstrap 4页宽标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a working navbar, but how to get a pagewide bar above the navbar (Pagewide div). In mobile view the bar can disappear.

<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>

推荐答案

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

The fixed-top navbar is always on top.

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

To put your header bar above it, determine how tall you want the pagewide bar, and set the top: space above the fixed navbar. Use a media query to hide on smaller screens.

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

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

    .pagewide {
        height: 54px;
    }
}

这篇关于导航栏上方的Bootstrap 4页宽标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:59