即可滚动的绝对表格单元格

时间:2016-07-14 21:36:34

标签: html css internet-explorer

我尝试创建可滚动的侧面菜单。我用桌子式电池做了。  这是我的小提琴:https://jsfiddle.net/y6aq3oub/3/  代码:

#container {
  display:table;
}
#footer {
  width:100%;
  height:20px;
  background-color:white;
  border: 1px solid black;
}

.absolute-menu {
  position: absolute;
  overflow-y: auto;
  width: 100%;
  height: 100%
}
.column {
  display:table-cell;
  position: relative;
  vertical-align:top;
}
#col1 {
  width:25%;
  background-color:red;
}
#col2 {
  background-color:blue;
}
<div id="container">
  <div id="col1" class="column">
    <div class="absolute-menu">
      <div>1</div>
      <div>2</div>
      <div>3</div>
      <div>4</div>
      <div>5</div>
      <div>6</div>
      <div>7</div>
    </div>
  </div>
  <div id="col2" class="course-column">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula     eget dolor. Aenean massa. 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula     eget dolor. Aenean massa. 
  </div>
</div>
<div id="footer"></div>

但IE8-IE11中菜单的高度为零。我发现了几个类似的问题,但他们的解决方案并没有帮助我

例如:IE display: table-cell child ignores height: 100% 要求:

  • col1 height = col2 height
  • col2 height是动态的
  • col1溢出内容应该是可滚动的

1 个答案:

答案 0 :(得分:0)

我找到了解决方案https://jsfiddle.net/y6aq3oub/7/ 必须使用边距

.container {
  position: relative;
  display: inline-block;
  background: red; /* This will serve as a background for a menu. */
}

.absolute-menu {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  width: 25%; /* You'll have to sync this... */
}

.course-column {
  margin-left: 25%; /* ... and this. */
  background-color: blue;
}

#footer {
  width:100%;
  height:20px;
  background-color:white;
  border: 1px solid black;
}