A colorful css gradient background generator
Check this website to see the generator in action and play with the colors settings.
The idea is to have multiple layers of linear css gradients at different angles. The gradients go from color to transparent to let the lower layers shine through and generate the wanted effect. There is no limit in the number of layers.
There are two ways to use this generator:
- Include the generator in the website
- Use it just as a code generator
There are examples in the
1. Include the generator in the website
Add the generator (it's in the
dist folder) to your html file and let it set the background to the element directly.
This element will have the colorful background.
2. Use it just as code generator
Another way is to use the generator to generate the css for the background and add this generated css to your style.css.
Generate the css class
- Choose a high saturation between
- Choose a lightness between
- The lowest (first added) layer should have the
50to make the lowest layer more colorful then the other layers
The only magic are css gradients. So it works with
- Firefox 16+
- Safari 5.1+
- Chrome 10+
- Internet Explorer 10+
- Opera 12.1+
- iOS 5.1+
- Android 4+
- Blackberry 10+
- IE Mobile 10+
See http://caniuse.com/#feat=css-gradients for more details on css gradients.
Transparency in Firefox
This is fixed in Firefox 36+ but an issue in earlier versions.
Firefox renders transparency in gradients different than webkit. The trick is to not use
rgba(0,0,0,0) but the first color with alpha transparency = 0.
/* This fades to gray first before fading to transparent. *//* This fades from color to transparent. */
Open this fiddle with Firefox version 16 till 35 to see the difference.
Degrees counting in webkit
-webkit-linear-gradientis counting degrees counterclockwise.
0° is at the left side.
- The standard
linear-gradientis counting degrees clockwise.
0° is at the bottom side.
To convert the degrees of the standard linear-gradient to the -webkit-prefix degrees: (360 - standard-degrees) + 90
Open this fiddle in Chrome 26+ (or Safari 6.1+) to see the difference.
The MIT License (MIT)
Copyright (c) 2014 webcore-it
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.