您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何检测div元素中的溢出?

如何检测div元素中的溢出?

您可以通过将scrollHeight与clientHeight进行比较轻松地做到这一点,请尝试以下操作:

<script type="text/javascript">
function GetContainerSize ()
{
    var container = document.getElementById ("tempDiv");
    var message = "The width of the contents with padding: " + container.scrollWidth + "px.\n";
    message += "The height of the contents with padding: " + container.scrollHeight + "px.\n";

    alert (message);
}
</script>

有关更多信息,请查看:http ://help.dottoro.com/ljbixkkn.PHP

其他 2022/1/1 18:13:42 有590人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶