“Inspect” a hover element?

有些话、适合烂在心里 提交于 2019-11-27 10:54:36

If the hover effect is given with CSS then yes, I normally use two options to get this:

One, to see the hover effect when the mouse leave the hover area:
Open the inspector in docked window and increase the width until reach your HTML element, then right click and the popup menu must be over the inspector zone... then when you move the mouse over the inspector view, the hover effect keep activated in the document.

Two, to keep the hover effect even if the mouse is not over the HTML element, open the inspector, go to Styles TAB and click in the upper right icon that says Toggle Element State...(dotted rectangle with an arrow) There you can manually activate the Hover Event (among others) with the checkbox provided.

If it's not clear at all, let me know and I can add a few screenshots. Edited: screenshot added.

And finally and as I say at the begining, I only be able to do this if the hover is set with CSS:HOVER... when you control the hover state with jQuery.onMouseOver for example, only works (sometimes), the method One.

Hope it helps.

If the hover is triggered by JS, just pause script execution via the keyboard. This is a much simpler way of freezing the DOM than the other answers suggest.

Here's how you do it in Chrome. I'm sure Firefox has an equivalent procedure:

  1. Open up Developer Tools and go to Sources.
  2. Note the shortcut to pause script execution—F8.

  3. Interact with the UI to get the element to appear.

  4. Hit F8.
  5. Now you can move your mouse around, inspect the DOM, whatever. The element will stay there.

What worked for me is selecting the specific a tag I wanted to inspect and do this:

After doing the above, I would again normally select that a tag then the dropdown will automatically stay as-is even when I mouseover to other places like Inspect Element, etc.

You can just refresh the browser when doing inspecting the menu dropdown elements to go back to normal state.

Hope this helps. :)

You can also do this in the javascript console:

$('#foo').trigger('mouseover');

An that will "freeze" the element in the "hover" state.

Josh

Here's how I do it with no CSS changes or JS pausing in Chrome (I am on a Mac and do not have a PC in front of me if you are running on Win):

  1. have your developer console open.
  2. do not enable the hover inspection tool yet, but instead open up your desired sub menu by moving your mouse over it.
  3. hit Command+Shift+C (Mac) or Ctrl+Shift+C (Win/Linux)

now the hover inspection tool will apply to the elements you have opened in your sub-nav.

Not sure if it was present in previous browser revisions, but I just found out this extremely simple method.

Open the inspector in chrome or Firefox, right click on the element you are interested in, and select the appropriate option (in this case: hover). This will trigger the associated CSS.

Screenshots from Firefox 55 and chromium 61.

Excellent stuff!

Thank you to gmo for that advice. I did not know about those attribute settings massively helpful.

As a small revision to the wording I would explain that process as follows:

  • Right Click on the element you would like to style

    • Open 'Inspect' tool

    • On right hand side, navigate to the small Styles tab

    • Found above CSS stylesheet contents

    • Select the .hov option - This will give you all the settings available for the selected HTML element

    • Click and Change all options to be inactive

    • Now Select the state that you would like to tweak - On activation of any of these, your Stylesheet will jump you directly to those settings:

Styles - Tweaking Filters - Interactive elements

This information was a lifesaver for me, cannot believe I have just heard about it!

change the CSS so that the property which hides the menu isn't applied while you work on it is what I do.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!