我有一个div可滚动的内容,并且它是一个应该溢出其父级的标头。
似乎溢出:scroll添加溢出:隐藏到元素。
如果你能帮助我,我会很感激。谢谢!
HTML:
<div class="container">
<div class="problem">This is hidden</div>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
</div>
<div class="container container-2">
<div class="problem">This is what i want, but scrollable.</div>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
</div>
CSS:
.container {
width: 230px;
height: 200px;
background-color: #eeeeee;
overflow-y: scroll;
margin-top: 30px;
margin-left: 30px;
float: left;
}
.container-2 {
overflow-y: visible;
}
.problem {
width: 235px;
height: 30px;
background-color: #33CCFF;
margin-left: -20px;
margin-top: 15px;
}
答案 0 :(得分:1)
.problem {
width: 235px;
height: 30px;
background-color: #33CCFF;
/*margin-left: -20px;*/ //this is the cause of problem comment this
margin-top: 15px;
}