【问题标题】:div width auto collapsing when using overlayScrollbars.js使用overlayScrollbars.js时div宽度自动折叠
【发布时间】:2018-06-18 15:23:05
【问题描述】:

我遇到了overlayScrollbars 的问题。

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

Bare Bones 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;
}

NB - 我已经省略了用于包含在笔中的 overlayScrollbars 的内联 JS 和 CSS(没有可用的 CDN)。

【问题讨论】:

    标签: jquery css


    【解决方案1】:

    原来是#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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-16
      • 2011-08-22
      • 2021-12-12
      • 1970-01-01
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多