There are often times when gradient backgrounds are needed. It is a little too small to use a long image, so I wrote a small example myself. To be compatible with multiple browsers, I had to write the corresponding CSS for each browser, browsers of earlier versions can only use images as backgrounds.
The following figure shows gradient support for the five browsers.
CSS code
- <Style type = "text/CSS" Media = "screen">
- # Gradient {
- Width: 200px;
- Height: 200px;
- /* If the browser does not support gradient, use the image as the background */
- Background: url(gradient.jpg );
- /* WebKit: Safari 4-5, chrome 1-9 */
- Background:-WebKit-gradient (linear, 0% 0%, 0% 100%, from (# ff6600), to (#339900 ));
- /* WebKit: safari 5.1 +, chrome 10 + */
- Background:-WebKit-linear-gradient (top, # ff6600, #339900 );
- /* Firefox 3.6 + */
- Background:-moz-linear-gradient (top, # ff6600, #339900 );
- /* Operators' 11.10 + */
- Background:-o-linear-gradient (top, # ff6600, #339900 );
- /* Ie 10 */
- Background:-MS-linear-gradient (top, # ff6600, #339900 );
- /* Ie <10 */
- /* Note: This line must be written at the end */
- Filter: progid: DXImageTransform. Microsoft. gradient (startcolorstr = # ff6600, endcolorstr = #339900 );}
- </Style>
HTML code
- <Div id = "gradient"> </div>
When there is no IE6, when the world is peaceful. Internet Explorer.