Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS- link to an icon visible on hover

Tags:

I have an icon that I display on top, right of a div on hovering over the div. My code is like this:

<div class='edit_hover_class'>    <!-- some code --> </div> 

And the corresponding css file contains:

.edit_hover_class:hover {   background: url("trash.gif") no-repeat scroll right top; } 

I want to attach a link to the edit icon, is it possible with plain css? If so, how?

like image 343
Appster Avatar asked Mar 08 '12 12:03

Appster


People also ask

How do you make something visible on hover 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 do you add a link to icon in CSS?

You can add a little icon to links to indicate what type of link it is. Instead of using a img tag for each link, you should use CSS to add them, by matching the URL. The CSS selector a[href*="twitter.com/"] matches any “a” tag with “href” attribute that has value contanining the string “twitter.com/”.

How do I hover an image in CSS?

Answer: Use the CSS background-image property You can simply use the CSS background-image property in combination with the :hover pseudo-class to replace or change the image on mouseover.

How do you show hover information in HTML?

HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .


1 Answers

You could hide a link until hover like so:

<div class='edit_hover_class'>    <a href='#'><img src='icons/trash.gif' /></a> </div>  .edit_hover_class a{   visibility:hidden; } .edit_hover_class:hover a {  visibility:visible; } 

See jsfiddle:

http://jsfiddle.net/Auzm5/

Or if you only want the icon to link, use CSS visibility:

http://jsfiddle.net/Auzm5/1/

like image 112
Curtis Avatar answered Oct 05 '22 18:10

Curtis