CSS over-flow:隐藏或滚动不适用于span

时间:2017-03-08 09:24:17

标签: javascript jquery html css

我有一个演示网站来显示文本数据。

在文本框中,用户插入太多字符。

所以,我希望它可以是一个滚动来显示所有文本。

我使用CSS的属性:

span {
   display: block;
   overflow: scroll;
   height: 150px;
}
<span>
I am a span<br/>
I am a span<br/>
I am a span<br/>
I am a span<br/>
I am a span<br/>
I am a span<br/>
I am a span<br/>
I am a span<br/>
<span>

但我无法向下滚动。

您可以在以下网址查看:

1 个答案:

答案 0 :(得分:1)

适合我吗?我怀疑你有另一个规则来覆盖这一个。尝试添加!important到overflow:scroll声明。

span {
   display: block;
   overflow: scroll !important;
   height: 150px;
}
<span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum venenatis, justo quis mollis volutpat, nibh enim</p>
</span>