Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover over a hidden element to show it

Tags:

Is there any way to hover over an element that's already hidden. I am trying to mimic what Steam does with their arrow navigation on their home page. You'll notice that when you first get to the page, there are no arrows showing:

enter image description here

Then when you hover over the area where there should be an arrow, it shows itself:

enter image description here

I've tried setting my divs that contain the arrow images to display: none and have also tried visibility: hidden but neither seems to work with the hover or mouseover methods in jQuery. I would have thought visibility: hidden would make it work, but that doesn't seem to be the case. Is there any other way I can hide these divs from the start but still be able to have hover events work on them?

like image 536
Aaron Avatar asked Dec 21 '11 19:12

Aaron


People also ask

How do you make elements visible on hover?

To display the element on hover, make them invisible by default using display: none property. Then add :hover property on that element with display: block to make it visible on hover.

How do you show hidden elements in HTML?

Style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery. To hide an element, set the style display property to “none”. document.

How do I show hidden elements in CSS?

You can hide an element in CSS using the CSS properties display: none or visibility: hidden. display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.


1 Answers

Set it to zero opacity instead:

$('#blah').hover(function() {     $(this).fadeTo(1,1); },function() {     $(this).fadeTo(1,0); }); 

http://jsfiddle.net/mblase75/bzaax/

like image 55
Blazemonger Avatar answered Sep 30 '22 18:09

Blazemonger