Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css hide button until div hover

Tags:

css

hide

We want to hide button until we hover over the div layer.

FIDDLE here > Click to view

Essentially, I would like to be able to apply this to other elements also, but this will do for now, any help appreciated

like image 671
422 Avatar asked Sep 26 '11 02:09

422


People also ask

How do I hide a div until hover?

You can do this by using the :hover property of a page element. For example, if we have a div inside another div, we can check the hover of the outer div to show/hide the inner div. This CSS hides the inner div by default using "display: none;".

How do you make a div hover in CSS?

To display div element using CSS on hover a tag: First, set the div element invisible i.e display:none;. By using the adjacent sibling selector and hover on a tag to display the div element.

How can you affect other elements when one element is hovered?

If you have two elements in your HTML and you want to :hover over one and target a style change in the other the two elements must be directly related--parents, children or siblings. This means that the two elements either must be one inside the other or must both be contained within the same larger element.


2 Answers

Simply use the :hover pseudo-class on the outer div:

.resultContainer .viewThisResult {
    display: none;
}
.resultContainer:hover .viewThisResult {
    display: inline;
}

Here's the fiddle: http://jsfiddle.net/dTLaF/1/

like image 179
Joseph Silber Avatar answered Oct 05 '22 12:10

Joseph Silber


.resultContainer:hover .viewThisResult { display: block; }

:hover pseudoselector on the parent. Though it's nice when the code for the question is included in the question, for posterity.

like image 30
Annika Backstrom Avatar answered Oct 05 '22 13:10

Annika Backstrom