![](/img/trans.png)
[英]How can I add a scrollbar to a div that has a parent div with overflow hidden?
[英]How do I add a border to a div that has the style='overflow:auto' only when the scrollbar is activated?
因此,我有一个div,它可以动态获取内容,并且当内容大小超过指定的高度时,overflow:auto就会启动,并且会显示一个滚动条,但在内容通过该高度边界之前不会出现。
现在,我应该仅在超过高度时才在整个div周围添加1px边框,并且滚动条显示出来……是否有人知道如何实现此目的? 我尝试过jquery,但是我无法抓住任何东西,因为从技术上讲,它不是单击之类的事件...
提前致谢
我认为这可能有效:
$('#div').bind('resize', function(){
if($(this).height() > DEFAULT_HEIGHT_OF_YOUR_DIV){
$(this).css({'border':'1px solid red'});
}
else{
$(this).css({'border':'0px'});
}
});
HTH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.