April 29, 2012

global COLOR opacity hover overlay?

Question by whoa

I’m using the below for a global link opacity overlay.

a:hover {
    text-decoration: none;  opacity: 0.6; /* css standard */
    filter: alpha(opacity=60); /* internet explorer */
} /* mouse over link */

How can I add color to this? Is this possible with CSS or am I looking at a JS / jQuery solution only?

Answer by trickeedickee

If you want the colour e.g. black to be on the background then your code will be

a:hover {text-decoration: none;  opacity: 0.6; /* css standard */
filter: alpha(opacity=60); /* internet explorer */ /* mouse over link */ background: #000; }

and if you want the a tag to have a colour of eg black then your css will look like this

a:hover {text-decoration: none;  opacity: 0.6; /* css standard */
filter: alpha(opacity=60); /* internet explorer */  /* mouse over link */ color: #000; }

for some reason you have an extra } in your code.

Answer by Starx

It seems you dont need opacity at all. The effect you are searching for is a tranparent background. Use rgba() with a rgb() fallback and define a transparent background instead.

a:hover {
    text-decoration: none;  
    background: rgb(255,0,0) /* fallback */
    background: rgba(255,0,0,0.6) /* red with 60% opactiy */
    color: #000;
} 

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!