CSS3 Transition: animating between 2 different gradients. incl jsfiddle - animation

http://jsfiddle.net/nicktheandroid/PXdXr/1/
I would like to animate between 2 different gradients, have one fade in on hover.
My example shows what should happen, but it happens instantly, i want it to fade between them.
Just for reference here on SO(this is all in the jsfiddle):
.outerBorder {
display:inline-block;
/*border: 3px solid #4d4d4d;*/
background: #4d4d4d; /* Old browsers */
background: -moz-linear-gradient(top, #4d4d4d 0%, #0e0e0e 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4d4d4d), color-stop(100%,#0e0e0e)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #4d4d4d 0%,#0e0e0e 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #4d4d4d 0%,#0e0e0e 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #4d4d4d 0%,#0e0e0e 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4d4d4d', endColorstr='#0e0e0e',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #4d4d4d 0%,#0e0e0e 100%); /* W3C */
-webkit-transition: background 1000ms ease-in-out;
-moz-transition: background 1000ms ease-in-out;
-o-transition: background 1000ms ease-in-out;
transition: background 1000ms ease-in-out;
}
.outerBorder:hover {
display:inline-block;
/*border: 3px solid #4d4d4d;*/
background: #d6f9ff; /* Old browsers */
background: -moz-linear-gradient(top, #d6f9ff 0%, #9ee8fa 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d6f9ff), color-stop(100%,#9ee8fa)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #d6f9ff 0%,#9ee8fa 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #d6f9ff 0%,#9ee8fa 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #d6f9ff 0%,#9ee8fa 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d6f9ff', endColorstr='#9ee8fa',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #d6f9ff 0%,#9ee8fa 100%); /* W3C */
}
.innerBox {
width:300px;
height:200px;
margin:5px;
background-color:#fff;
}

As Rick mentioned, there is no support for gradient animation yet.
However, you can still apply a semitransparent gradient on top of the CSS transition and then just animate the background color (the effect will be very similar):
.outerBorder {
display:inline-block;
/*border: 3px solid #4d4d4d;*/
-webkit-transition: background-color 1000ms ease-in-out;
-moz-transition: background-color 1000ms ease-in-out;
-o-transition: background-color 1000ms ease-in-out;
transition: background-color 1000ms ease-in-out;
background-color: #4d4d4d;
}
.outerBorder:hover {
background-color: #b4d7dd;
}
.innerBox {
width:300px;
height:200px;
padding:15px;
background-color:#fff;
background: -moz-linear-gradient(top, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.3)), color-stop(100%,rgba(255,255,255, 0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4d4d4d', endColorstr='#0e0e0e',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* W3C */
}
JSFiddle: http://jsfiddle.net/NAVYX/

There isn't support for gradient animations yet. As you are using jQuery you could write this functionality using cssHooks, or simpler, have one gradient on top of the other, then animate the opacity to simulate the fade.

Related

IE8 IE9 drop down menu inline error

My CSS Menu bar has a little problem. The bar works fine in all the other major browsers including IE10, but not in IE 8 or 9. It seem like the float or the inline-block is being ignored. They are shown as stacked on top of one another instead of side by side. If you have IE 8 or 9 you can view the problem at kitchenova.com. I have made a jsfiddle of the menu bar: http://jsfiddle.net/bLZzL/
IE will always be a pain!
#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
margin: 0;
padding: 0;
position: relative;
font-family:Verdana, Geneva, sans-serif
}
#cssmenu {
height: 30px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0px 0px;
-webkit-border-radius: 5px 5px 0 0;
background: #E0E0E0;
background: -moz-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #FFFFFF), color-stop(100%, #E0E0E0));
background: -webkit-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: -o-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: -ms-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: linear-gradient(to bottom, #FFFFFF 0%, #E0E0E0 100%);
border-bottom: 2px solid #EB2226;
z-index:999;
}
#cssmenu:after,
#cssmenu ul:after {
display: inline-block;
float:left;
}
#cssmenu a {
background: #E0E0E0;
background: -moz-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #FFFFFF), color-stop(100%, #E0E0E0));
background: -webkit-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: -o-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: -ms-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);
background: linear-gradient(to bottom, #FFFFFF 0%, #E0E0E0 100%);
color: #000000;
display: inline-block;
font-family: Verdana, Geneva, sans-serif
font-size: 15px;
line-height: 29px;
padding: 0 20px;
text-decoration: none;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul {
float: left;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #EB2226;
margin-left: -10px;
}
#cssmenu > ul > li:first-child > a {
border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
}
#cssmenu > ul > li:last-child > a {
border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
}
#cssmenu > ul > li.active > a {
}
#cssmenu > ul > li:hover > a {
background: #070707;
background: -moz-linear-gradient(top, #FFFFFF 0%, #BBBDBF 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #FFFFFF), color-stop(100%, #BBBDBF));
background: -webkit-linear-gradient(top, #FFFFFF 0%, #070707 100%);
background: -o-linear-gradient(top, #FFFFFF 0%, #BBBDBF 100%);
background: -ms-linear-gradient(top, #FFFFFF 0%, #BBBDBF 100%);
background: linear-gradient(to bottom, #FFFFFF 0%, #BBBDBF 100%);
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
}
#cssmenu .has-sub {
z-index: 1;
}
#cssmenu .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#cssmenu .has-sub ul li {
*margin-bottom: -1px;
}
#cssmenu .has-sub ul li a {
background: none repeat scroll 0 0 #E5E5E5;
border-bottom: 1px dotted #000000;
filter: none;
font-size: 12px;
display: block;
line-height: 120%;
padding: 10px;
}
#cssmenu .has-sub ul li:hover a {
background: #EB2226;
color:#FFF;
}
#cssmenu .has-sub .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#cssmenu .has-sub .has-sub ul li a {
background: #0c7fb0;
border-bottom: 1px dotted #6db2d0;
}
#cssmenu .has-sub .has-sub ul li a:hover {
background: #095c80;
}
This is the list it applies to:
<link href="assets/templates/v32029/css/Dropdown_style(8-6-2013).css" rel="stylesheet" type="text/css" />
<div id='cssmenu' style="position:relative;">
<ul>
<li class='active has-sub'><a href='http://www.kitchenova.com/Bakeware_c_8.html'><span>Bakeware</span></a>
<ul>
<li><a href='http://www.kitchenova.com/Measuring-Tools_c_407.html'><span>Measuring Tools</span></a></li>
<li><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bBaking%20%26%20Pastry%20Tools'><span>Baking and Pastry Tools</span></a></li>
<li><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bCookie%20%26%20Biscut%20Cutters'><span>Cookie and Biscuit Cutters</span></a></li>
<li><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bDecorating%20Tools'><span>Decorating Tools</span></a></li>
<li><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bPans%2c%20Molds%2c%20%26%20Sheets'><span>Pans, Molds, and Sheets</span></a></li>
<li><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bBaking%20Dishes'><span>Baking Dishes</span></a></li>
<li><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bSilicone%20Bakeware'><span>Silicone Bakeware</span></a></li>
<li class='last'><a href='http://www.kitchenova.com/search_results.html?&sn=162062355&e=ajx&srt=0&tag=CATSBakeware%3bMixing%20%26%20Prep%20Bowls'><span>Mixing and Prebowls</span></a></li>
</ul>
On you HTML code you used one TABLE above
<link href="assets/templates/v32029/css/Dropdown_style(8-6-2013).css" rel="stylesheet" type="text/css" />
Just need to set it's width 100%

Nesting background property

I want to nest "background" property. Can I do this in SCSS ?
background:{
#efefef;
linear-gradient(top, $backcolor 0%, #bbbbbb 100%);
-moz-linear-gradient(top, $backcolor 0%, #bbbbbb 100%);
-webkit-linear-gradient(top, $backcolor 0%,#bbbbbb 100%);
}
I'm not quite clear on what you mean by "nest", but i'm going to assume that means adding prefixed versions of background: linear-gradient. You can accomplish that with a simple mixin, or using Compass:
mixin
#mixin gradient ($solid, $start, $stop) {
background: $solid;
background: -moz-linear-gradient(top, $start 0%, $stop 100%);
background: -webkit-linear-gradient(top, $backcolor 0%, $stop 100%);
background: linear-gradient(top, $start 0%, $stop 100%);
}
body {
#include gradient(#efefef, $backcolor, #bbbbbb);
}
compass
body {
#include background(linear-gradient(top, $backcolor 0%, #bbbbbb 100%), #efefef);
}
I'd highly recommend compass if you are going to be doing a lot of work in SASS.

How do i find the right color combo for the transparent background color?

See image:
The grayed out area is actually an image.
How do i find the closest colors to create a similar color using css3?
I find the following colors the closest but not sure if they are a match since I don't know how to use them in CSS3:
5A5757 - Top
585555 - Bottom
Put this code into your css and set height.
background: #5a5757; /* Old browsers */
background: -moz-linear-gradient(top, #5a5757 0%, #5a5757 15%, #2b4244 15%, #2b4244 31%, #585555 31%, #585555 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#5a5757), color-stop(15%,#5a5757), color-stop(15%,#2b4244), color-stop(31%,#2b4244), color-stop(31%,#585555), color-stop(100%,#585555)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #5a5757 0%,#5a5757 15%,#2b4244 15%,#2b4244 31%,#585555 31%,#585555 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #5a5757 0%,#5a5757 15%,#2b4244 15%,#2b4244 31%,#585555 31%,#585555 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #5a5757 0%,#5a5757 15%,#2b4244 15%,#2b4244 31%,#585555 31%,#585555 100%); /* IE10+ */
background: linear-gradient(to bottom, #5a5757 0%,#5a5757 15%,#2b4244 15%,#2b4244 31%,#585555 31%,#585555 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#5a5757', endColorstr='#585555',GradientType=0 ); /* IE6-9 */

Gradient not working in Firefox – do I need specific color order?

If you look at http://jsfiddle.net/q2cFb/1/, you can see that both #b and #a is not working on Firefox (13.0.1). Why is that? It works on Chrome (with different syntax, but same colors).
Do I need to have some specific colors for gradient to work? Both #a and #c are using two colors, but #a isn't working.
HTML:
<div id='c'></div>
<div id='b'></div>
<div id='a'></div>
CSS:
#c {
background-image: -moz-linear-gradient(center bottom , #131315 37%, #272727 75%);
}
#b {
background-image: -moz-linear-gradient(center bottom , #242424 80%, #1E1E1E 58%, #191919 20%);
}
#a {
background-image: -moz-linear-gradient(center bottom , #242424 80%, #191919 20%);
}
The problem is that your percentages aren't in increasing order. See the MDN docs:
Color-stops must be specified in order.
try colorzilla it automatically does the css gradient coding for you.
example format for gradient for multibrowser
background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */
background: linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */

CSS3 Gradient not working in Firefox

For some reason my CSS Gradient isn't working in Firefox (v10.0.1). The main background for the page is supposed to be a gradient from white at the top down to a blueish colour, but in Firefox instead of a smooth gradient I'm just getting two solid blocks of colour, one white, one blue. In Chrome and Safari (on iPad & iPhone) it works perfectly.
Here is the test url for the page:
http://testing.xenongroupadmin.com/bitesize/login.html
And here is my CSS code:
body { font-family: arial, tahoma, verdana, sans-serif;
background: linear-gradient(bottom, #FFFFFF 42%, #CDEDFA 6%);
background: -o-linear-gradient(bottom, #FFFFFF 42%, #CDEDFA 6%);
background: -moz-linear-gradient(bottom, #FFFFFF 42%, #CDEDFA 6%);
background: -webkit-linear-gradient(bottom, #FFFFFF 42%, #CDEDFA 6%);
background: -ms-linear-gradient(bottom, #FFFFFF 42%, #CDEDFA 6%);
background: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.42, #FFFFFF),
color-stop(0.06, #CDEDFA));
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
width: 100%;
min-width:1350px;
}
I've tried searching for an answer but can't seem to find an example which matches my current predicament.
Thanks everyone
try this... its cross browser even works in ie6
.bodyGradient {
position: absolute;
top: 0;
left: 0;
border-top: 3px solid #93ae59;
z-index: -1;
background: -moz-linear-gradient(top, #cfddac, #fff);
background: -webkit-gradient(linear, left top, left bottom, from(#cfddac), to(#fff));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cfddac', endColorstr='#ffffff');
background: -o-linear-gradient(rgb(207,221,172),rgb(255,255,255));
}
use "background-image" instead of "background", like this example from http://gradients.glrzad.com/
background-image: -moz-linear-gradient(bottom, #DBA803 13%, #FFCA1D 57%, #FFF338 79%);
write this in your css
background-image: -moz-linear-gradient(top , #FFFFFF 62%, #CDEDFA 89%);
Better way to define gradient for all browsers
body {
background: linear-gradient(top , #FFFFFF 62%, #CDEDFA 89%);
background: -moz-linear-gradient(top , #FFFFFF 62%, #CDEDFA 89%);
background: -webkit-linear-gradient(top , #FFFFFF 62%, #CDEDFA 89%);
}

Resources