Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to MouseOver behind an object?

I'm trying to mouseover an image which is behind an another image.

Is there any way to render the front image like it is not there, so I can mouseover the other image behind it?

Example can be seen here: I can't mouseover the characters which are behind the logo boundingbox.

like image 274
Toykoc Avatar asked Oct 08 '14 12:10

Toykoc


People also ask

Is hover same as mouseover?

In the mouseover() method, it works the same as in the hover() method, but in the case of nested elements, When the cursor enters the outer part on which the mouseover event is attached, the mouseover() method gets called, but when the cursor enters the inner part, the mouseover() method calls again.

How do you do a mouse over?

In computing, a mouseover , mouse hover or hover box is a graphical control element that is activated when the user moves or hovers the pointer over a trigger area, usually with a mouse, but also possible with a digital pen.

How do you hover in Javascript?

jQuery hover() Method The hover() method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.

How do I make text hover in HTML?

What you'll want to do is enclose whatever text you'd like to have a mouseover in span tags. those look like this: <span>This is the text I want to have a mousover</span>. You can do this by either finding the text you want in the HTML editor, or by typing it yourself. Note that attribute values are always in quotes.


2 Answers

You can set the CSS property pointer-events: none on the obstructing object... but be aware that pointer events are all or nothing; mouseovers and hovers will pass right through, but so will clicks.

Here is a description of the value, from the Mozilla Developer's Network:

none: The element is never the target of mouse events; however, mouse events may target its descendant elements if those descendants have pointer-events set to some other value. In these circumstances, mouse events will trigger event listeners on this parent element as appropriate on their way to/from the descendant during the event capture/bubble phases.

I've put together a little example. In this example, I'm using onmouseover and onmouseout, since that's what you use on your website, but you could just as easily use the CSS :hover pseudo-selector. Here's a jsfiddle version of the example, and the stack snippet is below.

.hoverable {
  width: 100px;
  height: 100px;
  background-color: blue;
}

.obscuring {
  /* this first line is the important part */
  pointer-events: none;
  position: absolute;
  top: 50px;
  left: 50px;
  width: 100px;
  height: 100px;
  background-color: red;
  opacity: 0.5;
}
<div class="hoverable" onmouseover="this.style.backgroundColor = 'green'" onmouseout="this.style.backgroundColor = 'blue'"> </div>
<div class="obscuring"> </div>
like image 87
Woodrow Barlow Avatar answered Nov 07 '22 02:11

Woodrow Barlow


You can create some invisible divs on top of the whole thing and put the hover behaviour on them. Then control the characters position with the position of the invisible divs.

Hope it makes sense.

like image 44
Romeo Avatar answered Nov 07 '22 01:11

Romeo