哪个元素导致水平滚动条?自动检测 [英] Which element is causing the horizontal scrollbar? Automated detection
问题描述
网站和HTML应用程序上的水平滚动条通常不利于可用性和不需要的操作。它是非常常见的发现他们突然出现意外,我需要一个方法来快速调试和删除他们。
Horizontal scrollbars on web sites and HTML apps are generally bad for usability and unwanted. It's reasonably common to find them cropping up unexpectedly and I'm in need of a way to quickly debug and remove them.
什么是最快,最简单的方法在设计中找到令人讨厌的HTML元素?
是否有脚本或工具可以自动执行此操作?
通过您的页面逐个删除/隐藏元素,直到找到一个可疑,但这是费时,特别是如果有多个违规的元素。点击快捷方式或运行脚本,并将所有可疑元素突出显示,勾勒或打印到控制台上,这将是巨大的。
Yes, you can go through your page deleting/hiding elements one by one until you find a suspect, but this is time consuming, especially if there are multiple offending elements. It would be great to click a shortcut or run a script and have all the suspected elements highlighted, outlined or printed to the console.
澄清:问题不是如何以解决,但如何检测。
To clarify: the problem is not how to solve it, but how to detect it. I'd like a general solution which can work whenever this issue appears.
推荐答案
在更窄的范围内,你可以使用jQuery获取宽度)和 node.scrollWidth
以获取具有溢出其边界的内容的节点。
In a narrower scope, you can use jQuery (to get the width) and node.scrollWidth
to get nodes that have content that overflow their bounds.
http://jsfiddle.net/tomprogramming/v3Q6W/3/
这篇关于哪个元素导致水平滚动条?自动检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!