简体   繁体   English

检查Firebug或Chrome DevTools中的悬停状态

[英]Inspecting Hover-state in Firebug or Chrome DevTools

I've got an HTML element that has a CSS hover-state. 我有一个具有CSS悬停状态的HTML元素。 There's a bug with the margin or padding on hover and every time I mouseover, the contents of the element slide a little, its annoying. 悬停时有边距或填充的错误,每次鼠标悬停时,元素的内容都会滑动一点,这很烦人。

I'd like to debug using FireBug or Chrome Dev Tools, but a common problem I've had with these tools is that after I select the element from Firebug/devtools I obviously need to move the mouse back to the dev tools and the hover state is no longer enabled. 我想使用FireBug或Chrome Dev Tools进行调试,但我使用这些工具时遇到的一个常见问题是,在从Firebug / devtools中选择元素后,我显然需要将鼠标移回开发工具和悬停状态不再启用。

How do I inspect/debug an HTML element using these tools with the element in its hover state? 如何在悬停状态下使用这些工具检查/调试HTML元素?

Chrome Dev Tools has a built-in :hover state selector in the Elements > Styles panel. Chrome开发者工具在“元素”>“样式”面板中有一个内置:悬停状态选择器。 You can toggle other pseudo-classes (like :active) there as well. 您也可以切换其他伪类(如:active)。

For testing :hover states in Chrome 用于测试 Chrome中的 悬停状态

在此输入图像描述

For testing :hover state in Firefox (You need firebug add on) 用于测试 Firefox中的 悬停状态(你需要使用firebug

在此输入图像描述

Here's a screen shot for firebug & those not sharp enough to see agriboz's comment (like me) 这是一个针对firebug的屏幕截图以及那些不够敏锐的人看到agriboz的评论(像我一样)

在此输入图像描述

Now you can see both the pseudo-class style rules and force them on elements. 现在,您可以看到伪类样式规则并强制它们在元素上。

To see the rules like :hover in the Styles pane click the small dotted box button in the top right. 要查看以下规则:将鼠标悬停在“样式”窗格中,请单击右上角的小虚线框按钮。

To force an element into :hover state, right click the element. 要强制元素进入:悬停状态,请右键单击该元素。

Alternatively, you can use Event Listener Breakpoints sidebar pane in the Scripts panel and select to pause in mouseover handlers. 或者,您可以使用“脚本”面板中的“事件侦听器断点”侧栏窗格,并选择在鼠标悬停处理程序中暂停。

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

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