垂直滚动100%高度div

时间:2017-08-25 08:15:41

标签: html css overflow vertical-scroll

我尝试在100%高度div中创建一个水平滚动条。在jsfiddle中,右侧的滚动条应仅在内容表中可见,但当前滚动条在y轴上滚动孔页,而不仅在内容表y轴中滚动。

溢出:auto只能在x轴上工作,为什么不在y?

.content-table {
  white-space: nowrap;
  overflow: auto;
}

https://jsfiddle.net/mnlfischer/4g979nym/1/

2 个答案:

答案 0 :(得分:0)

这是因为你需要一个.content-table的高度尝试包括这个CSS高度:calc(100% - 100px);

答案 1 :(得分:0)

试试这个。



html, body{
  margin:0;
  overflow: hidden;
}
.container {
    width: 100%;
    height: 100vh;
    margin: 0;
    overflow: auto;
}

.column-lead {
  white-space: nowrap;
  overflow-x: auto;
}

.column-lead-item {
  width: 200px;
  background-color: lightgreen;
  display: inline-block;
  padding: 30px 10px;
}

.row-lead {
  float: left;
  overflow-y: auto;
  height: 100vh;
}

.row-lead-item {
  padding: 30px 10px;
  width: 200px;
  background-color: yellow;
}

.content-table {
  white-space: nowrap;
  overflow: auto;
  height: 100vh;
}

.content-table-row {
  width: 100%;
}

.content-table-item {
  display: inline-block;
  width: 200px;
  padding: 30px 10px;
  background-color: green;
}

<div class="container">

  <div class="row-lead">
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
    <div class="row-lead-item">Row Lead Item</div>
  </div>
  
  
  
  <div class="content-table">
    <div class="column-lead">
    <div class="column-lead-item">Column Lead Item</div>
    <div class="column-lead-item">Column Lead Item</div>
    <div class="column-lead-item">Column Lead Item</div>
    <div class="column-lead-item">Column Lead Item</div>
    <div class="column-lead-item">Column Lead Item</div>
    <div class="column-lead-item">Column Lead Item</div>
    <div class="column-lead-item">Column Lead Item</div>
  </div><div class="content-table-row">
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
    </div>
    <div class="content-table-row">
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
    </div>
    <div class="content-table-row">
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
    </div>
    <div class="content-table-row">
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
    </div>
    <div class="content-table-row">
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
    </div>
    <div class="content-table-row">
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
      <div class="content-table-item">Content Cell</div>
    </div>
  </div>
  
</div>
&#13;
&#13;
&#13;