Home > Web Front-end > CSS Tutorial > How Can I Create a Cross-Browser Linear Gradient?

How Can I Create a Cross-Browser Linear Gradient?

Mary-Kate Olsen
Release: 2024-11-21 10:56:11
Original
371 people have browsed it

How Can I Create a Cross-Browser Linear Gradient?

Using Linear Gradient Across Browsers

To achieve a cross-browser linear gradient, it's essential to account for differences between browsers. Here are the alternatives for Opera and Internet Explorer (IE):

Opera

background-image:     -o-linear-gradient(right, #0c93C0, #FFF);
Copy after login

Internet Explorer

IE < 10

/*IE7-*/ filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#0c93c0', endColorStr='#FFFFFF', GradientType=0);

/*IE8+*/
-ms-filter: "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#0c93c0', endColorStr='#FFFFFF', GradientType=0)";
Copy after login

IE10

background-image:     -ms-linear-gradient(right, #0c93C0, #FFF);
Copy after login

Modifying to Horizontal Gradient

To create a horizontal gradient, use the left or right direction instead of top or bottom.

Experimental CSS Prefixes

Note that experimental CSS properties use prefixes to indicate the browser they are intended for:

  • -webkit- for Webkit browsers (Chrome, Safari)
  • -moz- for Firefox
  • -o- for Opera
  • -ms- for Internet Explorer

Microsoft Gradient Filter Syntax

For IE, the -ms-filter syntax is as follows:

-ms-filter: progid:DXImageTransform.Microsoft.Gradient(
    startColorStr='#0c93c0', /*Start color*/
    endColorStr='#FFFFFF',   /*End color*/
    GradientType=0           /*0=Vertical, 1=Horizontal gradient*/
);
Copy after login

GradientType is optional and can be omitted.

The above is the detailed content of How Can I Create a Cross-Browser Linear Gradient?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template