I’m trying to create my first css-transitions, but it doesn’t work. I have tried using shortcode, putting the transitions in .btn-zen-inverse:hover instead. Why isn’t it working? (testing in the latest version of chrome)
.btn {
color: white;
font-family: 'ZLight';
border: 2px solid white !important;
box-shadow: 0 0 6px rgba( 12, 41, 63, 0.3);
text-shadow: none;
background: -moz-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.21) 100%);
/* FF3.6+ */
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.21) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.21) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.21) 100%);
/* IE10+ */
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.21) 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#6bffffff', GradientType=0);
/* IE6-9 */
padding: 3px;
}
.btn:hover {
transition: background-image 0.5s;
transition: background-color 0.5s;
-moz-transition: background-image 0.5s;
/* Firefox 4 */
-webkit-transition: background-image 0.5s;
/* Safari and Chrome */
-webkit-transition: background-color 0.5s;
/* Safari and Chrome */
-o-transition: background-image 0.5s;
/* Opera */
color: white;
}
.btn-zen-inverse {
background-color: #273032;
}
.btn-zen-inverse:hover {
background-image: none;
background-color: #273032;
}
<a class="btn btn-zen-inverse btn-large">
<span>Prova Zenconomy Gratis</span>
</a>
First of all, your transition definition needs to be a part of the base class definition
ie:
instead of:
and the actual change “effect”, if you will, is placed in the hover pseudo-class
like this:
and your base class definition:
That being said, I’m 99.7% sure you cannot break-apart the background “short-hand” style. Try seperating the individual styles you are attempting to transition (ie: background-color and background-image) in both the base class and the pseudo-class definitions.
EDIT: Apparently you CAN transition gradients, just not to “none”.