Compatible with gradient color backgrounds of multiple browsers

Source: Internet
Author: User
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
  1. <Style type = "text/CSS" Media = "screen">
  2. # Gradient {
  3. Width: 200px;
  4. Height: 200px;
  5. /* If the browser does not support gradient, use the image as the background */
  6. Background: url(gradient.jpg );
  7. /* WebKit: Safari 4-5, chrome 1-9 */
  8. Background:-WebKit-gradient (linear, 0% 0%, 0% 100%, from (# ff6600), to (#339900 ));
  9. /* WebKit: safari 5.1 +, chrome 10 + */
  10. Background:-WebKit-linear-gradient (top, # ff6600, #339900 );
  11. /* Firefox 3.6 + */
  12. Background:-moz-linear-gradient (top, # ff6600, #339900 );
  13. /* Operators' 11.10 + */
  14. Background:-o-linear-gradient (top, # ff6600, #339900 );
  15. /* Ie 10 */
  16. Background:-MS-linear-gradient (top, # ff6600, #339900 );
  17. /* Ie <10 */
  18. /* Note: This line must be written at the end */
  19. Filter: progid: DXImageTransform. Microsoft. gradient (startcolorstr = # ff6600, endcolorstr = #339900 );}
  20. </Style>

HTML code
  1. <Div id = "gradient"> </div>
When there is no IE6, when the world is peaceful. Internet Explorer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.