jquery - 使用 overlayScrollbars.js 时 div 宽度自动折叠

标签 jquery css

我遇到了 overlayScrollbars 的问题.

我有一个简单的布局、固定的左侧面板和页脚,内容可调整大小(和可滚动)。

基本的 css 工作正常:CodePen1

但是当我尝试添加 overlayScrollbars 来设置滚动条的样式时,内容 div 宽度会折叠:CodePen2

有什么办法解决这个问题吗?

HTML

<div id="panel"></div>

<div id="content">
  <div class="container">
    Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
  </div>
</div>

<div id="footer"></div>

CSS

html, body {
  height:100%;
  margin: 0;
  padding: 0;
  color: #808080;
  font-family: arial;
  line-height: 1.5rem;
}

#panel {
  float: left;
  left: 0;
  width: 255px;
  background: #F1F1F1;
  box-sizing: border-box;
  display: block;
  height: 100%;
  position: fixed;
}

#content {
  width: auto;   
  float: left;
  margin-left: 255px;
  position: fixed;
  box-sizing: border-box;
  height: 100%;
  overflow-x: auto;
}

#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 70px;
  width: 100%;
  box-sizing: border-box;
  display: block;
  background: #F1F1F1;
}

.container {
  position: relative;
  padding: 20px 20px 90px 20px;
  box-sizing: border-box;
}

注意 - 我省略了笔中包含的 overlayScrollbars 的内联 JS 和 CSS(没有可用的 CDN)。

最佳答案

原来是 #content div 中的 floatposition 属性。 删除它们,然后将 z-index 添加到 #footer div 修复它。

Working Codepen

#content {
  width: auto;   
  margin-left: 255px;
  box-sizing: border-box;
  height: 100%;
  overflow-x: auto;
}

#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 70px;
  width: 100%;
  box-sizing: border-box;
  display: block;
  background: #F1F1F1;
  z-index: 10;
}

关于jquery - 使用 overlayScrollbars.js 时 div 宽度自动折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50912752/

相关文章:

javascript - Datepicker - 计算不包括节假日和周末的天数

javascript - jQuery/Javascript : Waiting for an animation to finish

javascript - 在手机上查看时隐藏边框

javascript - 如何让 parent div 单击项目元素和模式上的类

javascript - 如何隐藏没有ID的div

html - CSS 内容属性在 IE 中不起作用

javascript - 选择新表时删除以前的表

javascript - Zurb 披萨饼图越来越大

javascript - 在桌面上向下滚动但不是在移动设备上向下滚动的三个 js 动画?

css - 供应商前缀对于在 @keyframe 中写入供应商前缀是否重要?