CSS3 gradient background compatibility issues

CSS3 gradient background compatibility issues

When we make a gradient background color, we will use the linear-gradient() function to create a linear gradient "image". It is the syntax in CSS3, and is compatible with IE10 at least

background-image: linear-gradient(to right, #ff9000, #ff5000);

direction: used to specify the gradient direction. It can accept an angle value (available in deg, rad, grad, or turn) or a direction keyword (top, right, bottom, left, left top, top right, bottom right, or left bottom).

color-start, color-end: indicates the starting color and ending color respectively

This is an example of Taobao's navigation bar, and its gradient color is implemented as follows:

background-image: linear-gradient(to right, #ff9000, #ff5000);

However, linear-gradient() is compatible with IE10 at least. To be compatible with IE8 and IE9, you can only use filter instead, as follows:

background-image: linear-gradient(to right, #ff9000, #ff5000);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff9000', 
endColorstr='#ffff5000', GradientType=1);
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff9000', 
endColorstr='#ffff5000', GradientType=1);

When we use filters to achieve gradients, we must pay attention to the fact that the color value cannot be filled in with abbreviations (such as #000), but must be written in full. Let's take a look at the difference between #000 and #000000:

When it is #000

filter:progid:DXImageTransform.Microsoft.gradient
(startColorstr='#000',
 endColorstr='#ffff5000', 
GradientType=1)
;

Execution Result:

When it is #000000

filter:progid:
DXImageTransform.Microsoft.gradient
(startColorstr='#000000', 
endColorstr='#ffff5000', GradientType=1);

Execution Result:

Next, let's analyze the value in the filter:

Careful friends can see that there are two more ff in the startColorstr and endColorstr color values ​​in the filter. In fact, startColorstr and endColorstr do not simply represent colors. Their format should be #AARRGGBB. AA, RR, GG, BB are positive hexadecimal integers. The value range is 00 - FF. RR specifies red values, GG specifies green values, and BB specifies blue values. AA specifies transparency. 00 is completely transparent. FF is completely opaque. Values ​​outside the range will be restored to the default value. The value range is #FF000000 - #FFFFFFFF. AA is similar to the a in rgba() we learned before, both of which are used to set transparency.

GradientType=1 indicates direction, 1 indicates horizontal direction, 0 indicates vertical direction

This is the end of this article about the compatibility issues of gradient background implementation in CSS3. For more relevant CSS3 gradient background content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  The tdwidth setting of the table in multiple divs is the same and cannot be aligned

>>:  Introduction to Spark and comparison with Hadoop

Recommend

Detailed graphic tutorial on installing centos7 virtual machine in Virtualbox

1. Download centos7 Download address: https://mir...

Solution to no Chinese input method in Ubuntu

There is no solution for Chinese input method und...

Docker View JVM Memory Usage

1. Enter the host machine of the docker container...

How to install and configure mysql 5.7.19 under centos6.5

The detailed steps for installing mysql5.7.19 on ...

How to deploy tomcat in batches with ansible

1.1 Building the Directory Structure This operati...

JavaScript Interview: How to implement array flattening method

Table of contents 1 What is array flattening? 2 A...

Docker uses dockerfile to start node.js application

Writing a Dockerfile Taking the directory automat...

How to recover files accidentally deleted by rm in Linux environment

Table of contents Preface Is there any hope after...

Summary of Linux commands commonly used in work

Use more open source tools such as docker and kub...

Vue.js implements calendar function

This article example shares the specific code of ...

A collection of common uses of HTML meta tags

What is a mata tag The <meta> element provi...

Detailed explanation of HTML basics (Part 2)

1. List The list ul container is loaded with a fo...

Vue3 navigation bar component encapsulation implementation method

Encapsulate a navigation bar component in Vue3, a...