简体   繁体   English

Javascript:如何识别“div”是否溢出?

[英]Javascript: How to identify if a “div” is overflowed?

I have a div with overflow: auto (a vertical scroll bar appears if the div contains a lot info). 我有一个带overflow: autodiv overflow: auto (如果div包含很多信息,则会出现垂直滚动条)。

How could I identify at some point if the vertical scroll bar appears or not ? 如何在某些时候识别是否出现垂直滚动条?

From http://bytes.com/topic/javascript/answers/157924-detect-if-scrollbars-visible-inside-div : 来自http://bytes.com/topic/javascript/answers/157924-detect-if-scrollbars-visible-inside-div

if (document.getElementById('divID').scrollHeight > document.getElementById('divID').clientHeight)
{
//a vertical scroll bar is present
}
else
{
//a vertical scroll bar is NOT present
}

这里已经回答

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

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