js控制div超出屏幕高度后自动出现滚动条方法:
<script language="javascript" type="text/javascript"> $(document).ready(function() { // 浏览器的高度和div的高度 var height = $(window).height(); var divHeight = $("#scolldiv").height(); //获取div对象 var divh = $("#scolldiv").get(0); //div高度大于屏幕高度把屏幕高度赋给div,并出现滚动条 if (divHeight > height-20) { divh.style.height = height-20; divh.style.overflow = "auto"; } }); </script> <div id="scolldiv" style="width: 100%;"><br /></div>
THE END