我有一个ul
包含在div
给定的特定宽度和高度内,并设置为overflow: auto
. 在文本可见的地方,background-color
正确填充了该区域:
...但是,当显示滚动区域时,不会background-color
扩展到溢出区域:
这是CSS:
.list_container {
height: 145px;
width: 150px;
border: 2px solid black;
/* for horizontal scrollbar: */
overflow: auto;
/* to prevent text from wrapping: */
white-space: nowrap;
}
#list {
height: 100%;
background-color: #EEEEEE;
/* getting rid of list styling: */
list-style-type: none;
}
/* getting rid of browser list indenting: */
#list, #list li {
margin: 0; padding: 0;
}
...和 HTML:
<div class = "list_container">
<ul id = "list">
<li>asdf asdf asdf asdf asdf asdf</li>
<li>qwerty qwerty qwerty qwerty</li>
<li>123 123 123 123 123 123 123 123</li>
<li>abc abc abc abc abc abc abc abc</li>
<ul>
</div>