粘边栏在Firefox中没有正确的顶部空间

时间:2019-06-27 20:43:56

标签: html css twitter-bootstrap bootstrap-4

我在使用Firefox时无法显示整个侧边栏。从图像中可以看出,它似乎无法与顶部正确隔开,从而隐藏了第一项!

Image 1

这是CSS:

/*
* Sidebar
*/

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100; /* Behind the navbar */
  padding: 0;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

.sidebar-sticky {
  position: -webkit-sticky;
  position: sticky;
  top: 48px; /* Height of navbar */
  height: calc(100vh - 48px);
  padding-top: .5rem;
  overflow-x: hidden;
  overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
}

.sidebar .nav-link {
  font-weight: 500;
  color: #333;
}

.sidebar .nav-link .feather {
  margin-right: 4px;
  color: #999;
}

.sidebar .nav-link.active {
  color: #007bff;
}

.sidebar .nav-link:hover .feather,
.sidebar .nav-link.active .feather {
  color: inherit;
}

.sidebar-heading {
  font-size: .75rem;
  text-transform: uppercase;
}

这是引导模板之一!

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

因为它位于网格内并使用响应类,所以当您缩小或放大窗口时,“间距”会改变。

<div class="row">
    <nav class="col-md-2 d-none d-md-block bg-light sidebar">
        <div class="sidebar-sticky">...</div>
    </nav>
    <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
        ...
    </main>
</div>