Be creative . This is an example of how I do gradient transitions without additional plugins.
I use 2 identical divs with different gradients, layered one on top of the other. Then I use jquery to animate the opacity on top.
Here it is step by step
- Create a wrapper with a fixed size, say, "width: 200px" and "height: 100px" (I use a wrapper to make it easier to adjust the position of sections within it).
- create 2 divs that are the same size as the wrapper, give both different background gradients, but use the same content for both visually, the only thing that changes is the background gradient.
- add "position: relative;" and adjust the position of the div to be on top, in this case box2 with "bottom: 100px;" (pay attention to the same value as the height of the wrapper and divs. This makes the div that will be on top to move up 100px positioning directly above the bottom div relative to the wrapper ... this is impossible without using "position: relative;" in the top div)
- animate the opacity of the div with your preferred method. I am using fadeToggle in this example.
HTML -----
<a href="#">Click to change gradient</a><br> <div align="center" style="width:200px; height:100px;"> <div style="width:200px; height:100px;" class="box1" id="box1">CONTENT BOTTOM DIV</div> <div style="width:200px; height:100px; position:relative;" class="box2" id="box2">CONTENT TOP DIV</div> </div>
GRADIENTS IN CSS -----
.box1 { background: rgb(237,144,23); background: -moz-linear-gradient(top, rgba(237,144,23,1) 0%, rgba(246,230,180,1) 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(237,144,23,1)), color-stop(100%,rgba(246,230,180,1))); background: -webkit-linear-gradient(top, rgba(237,144,23,1) 0%,rgba(246,230,180,1) 100%); background: -o-linear-gradient(top, rgba(237,144,23,1) 0%,rgba(246,230,180,1) 100%); background: -ms-linear-gradient(top, rgba(237,144,23,1) 0%,rgba(246,230,180,1) 100%); background: linear-gradient(top, rgba(237,144,23,1) 0%,rgba(246,230,180,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ed9017', endColorstr='#f6e6b4',GradientType=0 ); } .box2 { background: rgb(246,230,180); background: -moz-linear-gradient(top, rgba(246,230,180,1) 0%, rgba(237,144,23,1) 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(246,230,180,1)), color-stop(100%,rgba(237,144,23,1))); background: -webkit-linear-gradient(top, rgba(246,230,180,1) 0%,rgba(237,144,23,1) 100%); background: -o-linear-gradient(top, rgba(246,230,180,1) 0%,rgba(237,144,23,1) 100%); background: -ms-linear-gradient(top, rgba(246,230,180,1) 0%,rgba(237,144,23,1) 100%); background: linear-gradient(top, rgba(246,230,180,1) 0%,rgba(237,144,23,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6e6b4', endColorstr='#ed9017',GradientType=0 ); }
jQuery animation ----
$(document).ready(function(){ $("a").click(function(){ $("#box2").fadeToggle(100, "linear"); }); });
you can fold the third div so you don't have to write the same content twice, adding a second shell outside the first and placing the third div after closing the inner shell.
To view this, click on the following link ..
Link to an example