Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在不固定顶部值的情况下固定工具栏和侧边栏?_Jquery_Css_Twitter Bootstrap_Bootstrap 4 - Fatal编程技术网

Jquery 如何在不固定顶部值的情况下固定工具栏和侧边栏?

Jquery 如何在不固定顶部值的情况下固定工具栏和侧边栏?,jquery,css,twitter-bootstrap,bootstrap-4,Jquery,Css,Twitter Bootstrap,Bootstrap 4,我有一个固定的顶部工具栏和一个固定的侧边栏。我想把边栏放在工具栏的正下方,但不想把任何顶部值或边距放在顶部。可能吗?我已经用Bootstrap-4实现了这一点 <!-- Sidebar --> <nav id="sidebar" class="sticky-top sticky-offset"> ----------------- </nav> <nav class="navbar fixed-top"> ----------

我有一个固定的顶部工具栏和一个固定的侧边栏。我想把边栏放在工具栏的正下方,但不想把任何顶部值或边距放在顶部。可能吗?我已经用Bootstrap-4实现了这一点

<!-- Sidebar  -->
 <nav id="sidebar" class="sticky-top sticky-offset">
    -----------------
 </nav>

<nav class="navbar fixed-top">
   -------------
</nav>

<style>
.sticky-offset {
    top: 56px!important;
}
</style>

我不想使用top

您能否详细说明一下,为什么不想为您的容器放置任何top属性? 如果您的工具栏容器中有侧边栏容器,那么您想要的很容易实现。在这种情况下,可以使用位置为“固定”的工具栏;和带有位置的侧栏:绝对;:

HTML

看看这个提琴演示,也许它会让你走上正轨:

  <div class="navbar">
    <span>Toolbar</span>
    <div id="sidebar">
      <span>Sidebar</span>
    </div>
  </div>
.navbar {
  height: 50px;
  width: 100%;
  position: fixed;
  left: 0;
}

#sidebar {
  width: 50px;
  height: 190px;
  position: absolute;
  right: 0;
  top: 100%;
}