简体   繁体   English

尽管溢出被隐藏,但DIV滚动

[英]DIV scrolling despite overflow being hidden

I have a DIV that looks like this: 我有一个DIV看起来像这样:

<div style="height:300px;"> Content... </div> 

I'm using JavaScript to shorten the DIV height. 我正在使用JavaScript来缩短DIV高度。 After shortening it, I do not want the cut-off text to be readable. 缩短后,我不希望截断文本可读。 So I use: 所以我用:

$("div").css("height", "150px").css("overflow-y","hidden"); 

Using Chrome Inspector, I can tell that overflow-y is being applied, but the DIV is still scrollable after it is shortened, which I don't want. 使用Chrome Inspector,我可以知道正在应用overflow-y,但是将DIV缩短后仍然可以滚动,这是我不希望的。 How can I change this behavior? 我该如何改变这种行为?

have you tried 你有没有尝试过

$("div").css("height", "150px").css("overflowY","hidden"); 

The dash might be causing the issue 破折号可能是导致问题的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM