溢出:即使设置高度也自动不起作用

Overflow:auto not working even with height set

本文关键字:不起作用 高度 设置 溢出      更新时间:2023-09-26

在制作网站时,我在存储每个抛出的异常的一侧构建了一个异常持有者。

我想让它滚动,而不是在太多事情出错时扩展网页。

我正在使用CSS和overflow:auto来更改#error元素。

网站

#error {
  color:red;
  display:table;
  border:1px solid black;
  border-color:black;
  height:750px;
  width:10em;
  overflow:auto;
  white-space:nowrap;
}
#important{
  vertical-align:top;
  border-collapse:separate;
}
<table>
  <tr>
    <td id='error'>
      <div>
        <center>Errors:</center>
      </div>
    </td>
    <td id='important'>
      Everything here is important. Everything. Please wait while we load.
    </td>
  </tr>
</table>

#error中删除display:table;并将id='error'移动到嵌套div。它将解决问题。

#error {
  color: red;
  border: 1px solid black;
  border-color: black;
  height: 10px;
  width: 10em;
  overflow: auto;
  white-space: nowrap;
}
#important {
  vertical-align: top;
  border-collapse: separate;
}
<table>
  <tr>
    <td>
      <div id='error'>
        <center>
          Errors:
          <br/><br/><br/><br/>
          AAA
        </center>
      </div>
    </td>
    <td id='important'>
      Everything here is important. Everything. Please wait while we load.
    </td>
  </tr>
</table>