The Bootstrap button colors are defined thus in variables.less:
#btnPrimaryBackground: #linkColor;
#btnPrimaryBackgroundHighlight: spin(#btnPrimaryBackground, 20%);
#btnInfoBackground: #5bc0de;
#btnInfoBackgroundHighlight: #2f96b4;
#btnSuccessBackground: #62c462;
#btnSuccessBackgroundHighlight: #51a351;
#btnWarningBackground: lighten(#orange, 15%);
#btnWarningBackgroundHighlight: #orange;
#btnDangerBackground: #ee5f5b;
#btnDangerBackgroundHighlight: #bd362f;
#btnInverseBackground: #444;
#btnInverseBackgroundHighlight: #grayDarker;
Is there some logic in the hex codes for background and backgroundHighlight (i.e. specific color differences between the hex codes) or have they been set arbritrarily based on someone's design perspective that they 'look good'?
You can see that it was set specifically by design. But you could use lighten() or darken() mixins with 5% or 10% values to set highlights. But the same way you could make the whole button from one color :)
I took the relevant LESS code from Bootstrap's source to generate a btn-purple class. The gradient, etc are very similar to the default buttons. You just need to change #backgroundColor and #backgroundColorHighlight in the LESS code below to change the color.
// Gradient Bar Colors for buttons and alerts
.gradientBar(#primaryColor, #secondaryColor, #textColor: #fff, #textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
color: #textColor;
text-shadow: #textShadow;
#gradient > .vertical(#primaryColor, #secondaryColor);
border-color: #secondaryColor #secondaryColor darken(#secondaryColor, 15%);
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);
}
// Gradients
#gradient {
.horizontal(#startColor: #555, #endColor: #333) {
background-color: #endColor;
background-image: -moz-linear-gradient(left, #startColor, #endColor); // FF 3.6+
background-image: -webkit-gradient(linear, 0 0, 100% 0, from(#startColor), to(#endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(left, #startColor, #endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(left, #startColor, #endColor); // Opera 11.10
background-image: linear-gradient(to right, #startColor, #endColor); // Standard, IE10
background-repeat: repeat-x;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(#startColor),argb(#endColor))); // IE9 and down
}
.vertical(#startColor: #555, #endColor: #333) {
background-color: mix(#startColor, #endColor, 60%);
background-image: -moz-linear-gradient(top, #startColor, #endColor); // FF 3.6+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#startColor), to(#endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(top, #startColor, #endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(top, #startColor, #endColor); // Opera 11.10
background-image: linear-gradient(to bottom, #startColor, #endColor); // Standard, IE10
background-repeat: repeat-x;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(#startColor),argb(#endColor))); // IE9 and down
}
.directional(#startColor: #555, #endColor: #333, #deg: 45deg) {
background-color: #endColor;
background-repeat: repeat-x;
background-image: -moz-linear-gradient(#deg, #startColor, #endColor); // FF 3.6+
background-image: -webkit-linear-gradient(#deg, #startColor, #endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(#deg, #startColor, #endColor); // Opera 11.10
background-image: linear-gradient(#deg, #startColor, #endColor); // Standard, IE10
}
.horizontal-three-colors(#startColor: #00b3ee, #midColor: #7a43b6, #colorStop: 50%, #endColor: #c3325f) {
background-color: mix(#midColor, #endColor, 80%);
background-image: -webkit-gradient(left, linear, 0 0, 0 100%, from(#startColor), color-stop(#colorStop, #midColor), to(#endColor));
background-image: -webkit-linear-gradient(left, #startColor, #midColor #colorStop, #endColor);
background-image: -moz-linear-gradient(left, #startColor, #midColor #colorStop, #endColor);
background-image: -o-linear-gradient(left, #startColor, #midColor #colorStop, #endColor);
background-image: linear-gradient(to right, #startColor, #midColor #colorStop, #endColor);
background-repeat: no-repeat;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(#startColor),argb(#endColor))); // IE9 and down, gets no color-stop at all for proper fallback
}
.vertical-three-colors(#startColor: #00b3ee, #midColor: #7a43b6, #colorStop: 50%, #endColor: #c3325f) {
background-color: mix(#midColor, #endColor, 80%);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#startColor), color-stop(#colorStop, #midColor), to(#endColor));
background-image: -webkit-linear-gradient(#startColor, #midColor #colorStop, #endColor);
background-image: -moz-linear-gradient(top, #startColor, #midColor #colorStop, #endColor);
background-image: -o-linear-gradient(#startColor, #midColor #colorStop, #endColor);
background-image: linear-gradient(#startColor, #midColor #colorStop, #endColor);
background-repeat: no-repeat;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(#startColor),argb(#endColor))); // IE9 and down, gets no color-stop at all for proper fallback
}
.radial(#innerColor: #555, #outerColor: #333) {
background-color: #outerColor;
background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(#innerColor), to(#outerColor));
background-image: -webkit-radial-gradient(circle, #innerColor, #outerColor);
background-image: -moz-radial-gradient(circle, #innerColor, #outerColor);
background-image: -o-radial-gradient(circle, #innerColor, #outerColor);
background-repeat: no-repeat;
}
.striped(#color: #555, #angle: 45deg) {
background-color: #color;
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,.15)), color-stop(.75, rgba(255,255,255,.15)), color-stop(.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(#angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(#angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(#angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
background-image: linear-gradient(#angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
}
}
// Reset filters for IE
.reset-filter() {
filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
}
.buttonBackground(#startColor, #endColor, #textColor: #fff, #textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
// gradientBar will set the background to a pleasing blend of these, to support IE<=9
.gradientBar(#startColor, #endColor, #textColor, #textShadow);
*background-color: #endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */
.reset-filter();
// in these cases the gradient won't cover the background, so we override
&:hover, &:focus, &:active, &.active, &.disabled, &[disabled] {
color: #textColor;
background-color: #endColor;
*background-color: darken(#endColor, 5%);
background-position: 0 -15px;
}
// IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
&:active,
&.active {
background-color: darken(#endColor, 10%) e("\9");
}
}
// Provide *some* extra contrast for those who can get it
.btn-purple.active {
color: rgba(255,255,255,.75);
}
// Set the backgrounds
// -------------------------
#backgroundColor: lighten(#7a43b6, 10%);
#backgroundColorHighlight: darken(#7a43b6, 5%);
.btn-purple {
.buttonBackground(#backgroundColor, #backgroundColorHighlight);
}
Related
I am trying to make some LESS Mixin for graditent that will wotk in IE8, i know i can use gradient in IE8 like this
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */
This is juwt example, but what i need to make some custom mixin that will create that for IE8, this is CSS what i have
background-image: linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
background-image: -o-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
background-image: -moz-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
background-image: -webkit-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
background-image: -ms-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
What i need is to modified my LESS mixins that i created
.gradient (#startColor: #eee, #endColor: white) {
background-color: #startColor;
background: -webkit-gradient(linear, left top, left bottom, from(#startColor), to(#endColor));
background: -webkit-linear-gradient(top, #startColor, #endColor);
background: -moz-linear-gradient(top, #startColor, #endColor);
background: -ms-linear-gradient(top, #startColor, #endColor);
background: -o-linear-gradient(top, #startColor, #endColor);
}
For support for IE8 :)
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#startColor', endColorstr='#endColor',GradientType=0 ); /* IE6-9 */
But the problem is here
'#startColor'
In brackets, it does not recognize the variable
The traditional LESS compiler will not accept the filter property and will throw you an error. You simply use LESS Escaping for this problem as well. all you need to do is add the following line in your gradient and it should work just fine.
filter: ~”progid:DXImageTransform.Microsoft.gradient(startColorstr='#{startColor},
endColorstr='#{endColor})”;
This line will appear as it is in the code.
I just wanted to create a two color gradient using bootstrap mixin functions. So my gradient should be like this:
when using bootstrap gradient mixin I found there is no any function to match with my requirement. So I tried making my own gradient mixin and added it to bootstrap/less/mixins/grandients.less. But my function didn't do my job..
This is the gradient mixin I added to gradients.less
.vertical-custom(#start-color: #ed3537; #start-percent: 0%; #mid-color: #ed3537; #color-stop: 50%; #mid-color-2: #fb3e40; #color-stop-2: 50%; #end-color: #fb3e40; #end-percent: 100%) {
background-image: -webkit-linear-gradient(top, #start-color #start-percent, #mid-color, #color-stop, #mid-color-2, #color-stop-2, #end-color #end-percent); // Safari 5.1-6, Chrome 10+
background-image: -o-linear-gradient(top, #start-color #start-percent, #mid-color, #color-stop, #mid-color-2, #color-stop-2, #end-color #end-percent); // Opera 12
background-image: linear-gradient(to bottom, #start-color #start-percent, #mid-color, #color-stop, #mid-color-2, #color-stop-2, #end-color #end-percent); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
background-repeat: repeat-x;
//filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(#start-color),argb(#end-color))); // IE9 and down
}
I call it like this
#gradient.vertical-custom(#start-color: #ed3537; #start-percent: 0%; #mid-color: #ed3537; #color-stop: 50%; #mid-color-2: #fb3e40; #color-stop-2: 50%; #end-color: #fb3e40; #end-percent: 100%);
When I directly add pure CSS to my LESS file it working for me. But I am looking for a solution of creating a gradient mixin.
This is the pure CSS for my gradient:
background: #ed3537;
background: -moz-linear-gradient(top, #ed3537 0%, #ed3537 50%, #fb3e40 50%, #fb3e40 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ed3537), color-stop(50%,#ed3537), color-stop(50%,#fb3e40), color-stop(100%,#fb3e40));
background: -webkit-linear-gradient(top, #ed3537 0%,#ed3537 50%,#fb3e40 50%,#fb3e40 100%);
background: -o-linear-gradient(top, #ed3537 0%,#ed3537 50%,#fb3e40 50%,#fb3e40 100%);
background: -ms-linear-gradient(top, #ed3537 0%,#ed3537 50%,#fb3e40 50%,#fb3e40 100%);
background: linear-gradient(to bottom, #ed3537 0%,#ed3537 50%,#fb3e40 50%,#fb3e40 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ed3537', endColorstr='#fb3e40',GradientType=0 );
Hope somebody may help me out.
Thank you.
Bootstrap's gradients are namespaced (see: http://lesscss.org/features/#features-overview-feature-namespaces-and-accessors) and can be found in the less/mixins/gradients.less file.
A namespaced mixin should be called as follows:
#namespace > mixin();
The > is optional in this call.
Bootstrap provides you a .vertical-three-colors() mixin in the #gradient namespace which best matches your pure CSS.
You should calls this mixin as follows (for instance at the end of your bootstrap.less file):
div.gradient {
#gradient > .vertical-three-colors(#ed3537; #fb3e40; 50%; #fb3e40;);
}
The preceding outputs:
div.gradient {
background-image: -webkit-linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-image: -o-linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-image: linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-repeat: no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffed3537', endColorstr='#fffb3e40', GradientType=0);
}
Demo: http://codepen.io/bassjobsen/pen/ogjeJE
Notice that your pure CSS has support for more browsers than Bootstrap's mixin. The out depends on the way you compile bootstrap. The default build process generate the above output.
When you compile the following Less code with lessc --autoprefix="last 20 versions" grsdient.less:
div.gradient {
background-color: #ed3537;
background-image: linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-repeat: no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffed3537', endColorstr='#fffb3e40', GradientType=0);
}
that will output:
div.gradient {
background-color: #ed3537;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ed3537), color-stop(50%, #fb3e40), to(#fb3e40));
background-image: -webkit-linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-image: -moz-linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-image: -o-linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-image: linear-gradient(#ed3537, #fb3e40 50%, #fb3e40);
background-repeat: no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffed3537', endColorstr='#fffb3e40', GradientType=0);
}
The -ms-linear-gradient prefix only targets the developers version of IE10 and there is no need to use that in your production code.
Of course you can also write your own mixins which outputs exactly the same as your pure CSS:
.vertical-custom(#start-color: #ed3537; #start-percent: 0%; #mid-color: #ed3537; #color-stop: 50%; #mid-color-2: #fb3e40; #color-stop-2: 50%; #end-color: #fb3e40; #end-percent: 100%)
{
background: #start-color;
background: -moz-linear-gradient(top, #start-color, #mid-color #color-stop, #mid-color-2 #color-stop-2, #end-color #end-percent);
background: -webkit-gradient(linear, left top, left bottom, color-stop(#start-percent,#start-color), color-stop(#color-stop,#mid-color), color-stop(#color-stop-2,#mid-color-2), color-stop(#end-percent,#end-color));
background: -webkit-linear-gradient(top, #start-color #start-percent,#mid-color #color-stop,#mid-color-2 #color-stop-2,#end-color #end-percent);
background: -o-linear-gradient(top, #start-color #start-percent,#mid-color #color-stop,#mid-color-2 #color-stop-2,#end-color #end-percent);
background: -ms-linear-gradient(top, #start-color #start-percent,#mid-color #color-stop,#mid-color-2 #color-stop-2,#end-color #end-percent);
background: linear-gradient(to bottom, #start-color #start-percent,#mid-color #color-stop,#mid-color-2 #color-stop-2,#end-color #end-percent);
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(#start-color),argb(#end-color)));
}
now the following code:
div.gradient {
.vertical-custom();
}
outputs:
div.gradient {
background: #ed3537;
background: -moz-linear-gradient(top, #ed3537, #ed3537 50%, #fb3e40 50%, #fb3e40 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ed3537), color-stop(50%, #ed3537), color-stop(50%, #fb3e40), color-stop(100%, #fb3e40));
background: -webkit-linear-gradient(top, #ed3537 0%, #ed3537 50%, #fb3e40 50%, #fb3e40 100%);
background: -o-linear-gradient(top, #ed3537 0%, #ed3537 50%, #fb3e40 50%, #fb3e40 100%);
background: -ms-linear-gradient(top, #ed3537 0%, #ed3537 50%, #fb3e40 50%, #fb3e40 100%);
background: linear-gradient(to bottom, #ed3537 0%, #ed3537 50%, #fb3e40 50%, #fb3e40 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffed3537', endColorstr='#fffb3e40', GradientType=1);
}
Demo: http://codepen.io/bassjobsen/pen/LEpzEm
Make sure that the .vertical-custom mixin had been added inside the #gradient namespace in the gradients.less file when called with #gradient > .vertical-custom();
I have created a simple css bar with colour stops using the following:
#testing{
width:100%;
height:40px;
background-image: -webkit-linear-gradient(left, #034a96 80%, #eab92d 50%);
background-image: -moz-linear-gradient(top, #034a96 50%, #eab92d 51%);
background-image: -ms-linear-gradient(top, #034a96 50%, #eab92d 51%);
background-image: -o-linear-gradient(top, #034a96 50%, #eab92d 51%);
background-image: linear-gradient(top, #034a96 50%, #eab92d 51%);
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
}
What I would like to do is have the first 80% of the bar is have a gradient that goes from the top with colour #034a96 to #0663c7 and then just that gradient colouring 50% of the bar. Then with the other 51% I have another gradient from the top with #eab92d to #c79810. What I'm asking is if it is possible to have multiple gradients with in each other eg:
background-image: -webkit-linear-gradient(left, top #034a96 to #0663c7 50%, top #eab92d to #c79810 51%);
Or something along those lines. I hope I'm being clear with everything. Thanks in advance
Yes, you can.
One simple example (not exactly your colourset, but it shows the plan):
background: #b8e1fc; /* Old browsers */
background: -moz-linear-gradient(top, #b8e1fc 0%, #a9d2f3 10%, #90bae4 25%, #90bcea 37%, #90bff0 50%, #6ba8e5 51%, #a2daf5 83%, #bdf3fd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b8e1fc), color-stop(10%,#a9d2f3), color-stop(25%,#90bae4), color-stop(37%,#90bcea), color-stop(50%,#90bff0), color-stop(51%,#6ba8e5), color-stop(83%,#a2daf5), color-stop(100%,#bdf3fd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #b8e1fc 0%,#a9d2f3 10%,#90bae4 25%,#90bcea 37%,#90bff0 50%,#6ba8e5 51%,#a2daf5 83%,#bdf3fd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b8e1fc 0%,#a9d2f3 10%,#90bae4 25%,#90bcea 37%,#90bff0 50%,#6ba8e5 51%,#a2daf5 83%,#bdf3fd 100%); /* Opera 11.10+ */
background: linear-gradient(to bottom, #b8e1fc 0%,#a9d2f3 10%,#90bae4 25%,#90bcea 37%,#90bff0 50%,#6ba8e5 51%,#a2daf5 83%,#bdf3fd 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b8e1fc', endColorstr='#bdf3fd',GradientType=0 ); /* IE6-9 */
This code doesn't create multi-step gradients in IE.
Up to IE9, these aren't possible at all (only simple gradients), but IE9 supports SVG data. It's a bit complicated to write, but you should have a look at http://www.colorzilla.com/gradient-editor. It's an online-tool for creating CSS code for gradients. It also supports SVG gradients for IE9.
I generated gradient background in colorzilla and i put inside css file as u can see in this code and it keeps repeating me the background. I want this background to be from where it starts to the end of page.
body{
background: #1d6fa4;
background: -moz-linear-gradient(-45deg, #1d6fa4 1%, #499bc8 26%, #51abc9 52%, #3e94c1 74%, #277cad 100%);
background: -webkit-gradient(linear, left top, right bottom, color-stop(1%,#1d6fa4), color-stop(26%,#499bc8), color-stop(52%,#51abc9), color-stop(74%,#3e94c1), color-stop(100%,#277cad));
background: -webkit-linear-gradient(-45deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
background: -o-linear-gradient(-45deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
background: -ms-linear-gradient(-45deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
background: linear-gradient(135deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1d6fa4', endColorstr='#277cad',GradientType=1 );
}
You need this
html, body {
height: 100%;
}
body {
background-position: fixed;
/* Gradient dump goes here */
}
Is there any way to create a gradient background using nothing but CSS?
You can see an example of what I want to achieve on this website.
Use this in your CSS:
background-image: -o-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%);
background-image: -moz-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.24, rgb(254,133,107)), color-stop(0.62, rgb(35,171,17)));
background-image: -webkit-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%);
background-image: -ms-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%);
/* This last line is all you need for modern browsers */
background-image: linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%);
See also:
The specification
The MDN documentation
Simple and easy to make. Try this link
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);
/* Opera */
background-image: -o-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FCFEFF), color-stop(1, #AF00EF));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #FCFEFF 0%, #AF00EF 100%);
Use background-image with linear-gradient() or radial-gradient().
.linear-gradient {
background-image: linear-gradient(to bottom, #000077, #65A5FF);
}
.radial-gradient {
background-image: radial-gradient(#000077, #65A5FF);
}
div {
width: 100%;
height: 200px;
}
<h1>Linear gradient</h1>
<div class="linear-gradient"></div>
<h1>Radial gradient</h1>
<div class="radial-gradient"></div>
According to caniuse.com, CSS gradients are supported by all major browsers. If you have to support IE <= 9, use plain-color or image background fallback. If you have to support Android Browser <= 4.3, also use prefixed version (-webkit-linear-gradient).
.bckgrnd {
background-color:Green;
background-image: -webkit-gradient(linear, 0% 0%,0% 0%, from(Green), to(Yellow));
background-image: -webkit-linear-gradient(top, Green, Yellow);
background-image: -moz-linear-gradient(top, Green, Yellow);
background-image: -ms-linear-gradient(top, Green, Yellow);
background-image: -o-linear-gradient(top, Green, Yellow);
}
Try this website.
http://www.colorzilla.com/gradient-editor/
But there are also images and other things on this website, so if you want to copy the style, look how they have done it and try to implement it on your own ! There is also a website which has pretty neet background pattern's which, combined with gradients look absolutely rich and beautiful:
http://subtlepatterns.com/
A simple sample code for gradients which will be displayed in every browser:
background: rgb(243,226,199);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2YzZTJjNyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2MxOWU2NyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iI2I2OGQ0YyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNlOWQ0YjMiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(left, rgba(243,226,199,1) 0%, rgba(193,158,103,1) 50%, rgba(182,141,76,1) 51%, rgba(233,212,179,1) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(243,226,199,1)), color-stop(50%,rgba(193,158,103,1)), color-stop(51%,rgba(182,141,76,1)), color-stop(100%,rgba(233,212,179,1)));
background: -webkit-linear-gradient(left, rgba(243,226,199,1) 0%,rgba(193,158,103,1) 50%,rgba(182,141,76,1) 51%,rgba(233,212,179,1) 100%);
background: -o-linear-gradient(left, rgba(243,226,199,1) 0%,rgba(193,158,103,1) 50%,rgba(182,141,76,1) 51%,rgba(233,212,179,1) 100%);
background: -ms-linear-gradient(left, rgba(243,226,199,1) 0%,rgba(193,158,103,1) 50%,rgba(182,141,76,1) 51%,rgba(233,212,179,1) 100%);
background: linear-gradient(left, rgba(243,226,199,1) 0%,rgba(193,158,103,1) 50%,rgba(182,141,76,1) 51%,rgba(233,212,179,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f3e2c7', endColorstr='#e9d4b3',GradientType=1 );
background-image: linear-gradient(to bottom, #FFFFFF, #FAFAFA);
or
background: linear-gradient(#FFFFFF, #FAFAFA);
Add two div tag and give background color link this
<div style="background-color:black"> </div>
<div style="background: -moz-linear-gradient(top, #55aaee, #003366);"> </div>
This is not exact syntax this is an idea that how u can do