CSS transition fade on hover
Solution 1
I recommend you to use an unordered list for your image gallery.
You should use my code unless you want the image to gain instantly 50% opacity after you hover out. You will have a smoother transition.
#photos li {
opacity: .5;
transition: opacity .5s ease-out;
-moz-transition: opacity .5s ease-out;
-webkit-transition: opacity .5s ease-out;
-o-transition: opacity .5s ease-out;
}
#photos li:hover {
opacity: 1;
}
Solution 2
This will do the trick
.gallery-item
{
opacity:1;
}
.gallery-item:hover
{
opacity:0;
transition: opacity .2s ease-out;
-moz-transition: opacity .2s ease-out;
-webkit-transition: opacity .2s ease-out;
-o-transition: opacity .2s ease-out;
}
Related videos on Youtube
kwh71787
BY DAY: Senior WordPress Theme Developer at LinkNow Media BY NIGHT: PSD to WordPress Theme Developer at Element Web Designs. FOR FUN: Killing the biggest dragons I can find in either Final Fantasy XIV or World of Warcraft. Also, pwning noobs on Dota2 INSPIRATION: Give me six hours to chop down a tree and I will spend the first four sharpening the axe. -Abraham Lincoln
Updated on August 20, 2020Comments
-
kwh71787 over 3 years
I've encountered a problem with
CSS
transitions. I'm designing aCSS
gallery for my portfolio and I need my images to fade in on hover. I've been playing around with this for over an hour and I was hoping someone could point me into the right direction.Here is a simplified version to it with JSFiddle
-
giannis christofakis about 11 yearsYou forgot to place the seconds unit measurement on the
-moz-transition
-
Matt almost 10 yearsIt was having
opacity
set on the non-:hover element that caused my problem. -
SerKnight about 8 yearsAlso this will snap back at 0.0 speed when you release the hover