html - 调整 SideBar 的位置,使其位于 NavBar 固定顶部的 "front"

标签 html css twitter-bootstrap bootstrap-4

我的导航栏位于我的侧边栏之上。我需要的是侧边栏“覆盖”导航栏,这样当侧边栏消失时,导航栏就会可见。

由于侧边栏会折叠,因此发生这种情况时需要出现导航栏。就目前的情况而言,侧边栏看起来像是被切掉了,最终在侧边栏中失去了一个空间

侧边栏/导航栏图像:

enter image description here

<nav class="navbar navbar-light fixed-top  flex-md-nowrap p-0 shadow">
        <a class="navbar-brand   " href="#"> </a>
        <img src="~/Content/img/Principal_h_cor_RGB.png" alt="Logo" style="width:150px;">
        <ul class="navbar-nav px-3">
            <li class="nav-item text-nowrap">

            </li>
        </ul>
    </nav>

<nav id="sidebar" class="sidebar-wrapper">
            <div class="sidebar-content">
                <div class="sidebar-brand text-center">
                    <a href="#"></a>
                    <div id="close-sidebar">
                        <i class="fas fa-times"></i>
                    </div>
                </div>
                <div class="sidebar-header text-center">
                    <h6 style="text-align:center"> 
                        <img src="~/Content/img/boat_block2.png " alt="Logo" style="width:70px;" />
                    </h6>                                       
                    <div class="user-info">
                        <span class="user-name">
                            <strong>@Html.Partial("_LoginPartial")</strong> 

                        </span>
                        <!-- <span class="user-role">Administrator</span> -->
                        <span class="user-status">
                            <i class="fa fa-circle"></i>
                            <span>Online</span>
                        </span>
                    </div>
                </div>


                        </div>
                    </div>
                </div>
   </nav>

 <script>
.sidebar-wrapper {
    width: 260px;
    height: 100%;
    max-height: 100%;
    position: fixed;
    top: 0;
    left: -300px;
    z-index: 999;
    padding-top: 45px;
}

    .sidebar-wrapper ul {
        list-style-type: none;
        padding: 0;
        margin: 0;
    }

    .sidebar-wrapper a {
        text-decoration: none;
    }

最佳答案

只需将固定顶的Z-Index改为10

.fixed-top {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
}

关于html - 调整 SideBar 的位置,使其位于 NavBar 固定顶部的 "front",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53545944/

相关文章:

javascript - 如何确定用户是否选择了要上传的文件?

javascript - 有没有办法将 slider 重置为图像 1?

html - aria-descriptedby 但默认情况下为空文本错误 - 这是正确的吗?

javascript - 在 html 表中的父行下生成子行

jquery - 链接jquery添加类方法会触发多次回流吗?

html - Bootstrap Multiple Item Carousel 和 normal Carousel in a single page asp.net

javascript - 轮播与模板冲突

javascript - 如何向 javascript 游戏添加再玩一次的功能

jquery - 使用 jQuery 启动异步 CSS 动画

css - 容器宽度为 1170px,但当端口 View 宽度为 1280px 时,我预计为 970px