CSS3 Fadein/Fadeout Hover vs Jquery Fadein/Fadeout Hover
CSS3 Fadein Hover
html:
<ul>
<li>img
<div>
<span>put a desc here</span>
</div>
</li>
<li>img
<div>
<span>put a desc here</span>
</div>
</li>
<li>img
<div>
<span>put a desc here</span>
</div>
</li>
</ul>
css:
ul li {
display:inline-block;
margin-left:20px;
opacity:1;
border: 10px solid #fff;
position: relative;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-ms-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
-moz-box-shadow: 3px 3px 5px 6px #ccc;
-webkit-box-shadow: 3px 3px 5px 6px #ccc;
box-shadow: 3px 3px 5px 6px #ccc;
}
ul li, ul li div {
height: 100px;
width: 100px;
background: #999;
text-align: center;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
ul li div {
position:absolute;
background: #000;
color: #fff;
top:0;
left:0;
opacity: 0;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-ms-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
}
ul li div:hover {
opacity: 1;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-ms-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
}
ul li div span {
position: relative;
top: 30px;
}
DEMO
http://jsfiddle.net/itsduc/LEZcf/
Jquery Fadein Hover
html:
<ul>
<li>img
<div>
<span>put a desc here</span>
</div>
</li>
<li>img
<div>
<span>put a desc here</span>
</div>
</li>
<li>img
<div>
<span>put a desc here</span>
</div>
</li>
</ul>
css:
ul li {
display:inline-block;
margin-left:20px;
border: 10px solid #fff;
position: relative;
-moz-box-shadow: 3px 3px 5px 6px #ccc;
-webkit-box-shadow: 3px 3px 5px 6px #ccc;
box-shadow: 3px 3px 5px 6px #ccc;
}
ul li, ul li div {
height: 100px;
width: 100px;
background: #999;
text-align: center;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
ul li div {
position:absolute;
background: #000;
color: #fff;
top:0;
left:0;
display: none;
}
ul li div span {
position: relative;
top: 30px;
}
Jquery
$('ul li').hover(function() {
$(this).find('div').fadeIn();
}, function() {
$(this).find('div').fadeOut();
});
Written by Peony Gerochi
Related protips
4 Responses
Nice ... the CSS version seems to be too fast even though I tried to increase the "transition" just to see the fading effects .
Anyways nice tips.
over 1 year ago
·
Yeah, CSS3 is great for making those pretty disc transitions. Here's Codrops showing off: http://tympanus.net/codrops/2012/08/08/circle-hover-effects-with-css-transitions/
over 1 year ago
·
Thanks, I've changed all my fade in/out from js to css thanks this tutorial.
over 1 year ago
·
nice one,
thinking of converting it into social share bottons ... thanks
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css3
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#