I am trying to get this h3
to fade on hover. Can someone help me out?
HTML
<h3 class="clicker">test</h3>
CSS
.clicker { -moz-transition:color .2s ease-in; -o-transition:color .2s ease-in; -webkit-transition:color .2s ease-in; background:#f5f5f5;padding:20px; } .clicker:hover{ background:#eee; }
CSS transitions allows you to change property values smoothly (from one value to another), over a given duration.
This will animate the color property when you hover over a link on the page. Pretty simple, and you've probably seen or used something similar. But transitions are not just limited to use with :hover . You can animate CSS properties, thus use CSS transitions without hover.
To change the color/size of the button in hover state. Approach: Set the animation and time duration of hover state. Set background color using @keyframes.
What do you want to fade? The background
or color
attribute?
Currently you're changing the background color, but telling it to transition the color property. You can use all
to transition all properties.
.clicker { -moz-transition: all .2s ease-in; -o-transition: all .2s ease-in; -webkit-transition: all .2s ease-in; transition: all .2s ease-in; background: #f5f5f5; padding: 20px; } .clicker:hover { background: #eee; }
Otherwise just use transition: background .2s ease-in
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With