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 explanation of how to view the number of MySQL server threads

This article uses an example to describe how to v...

Detailed explanation of react setState

Table of contents Is setState synchronous or asyn...

CentOS 8 Installation Guide for Zabbix 4.4

Zabbix server environment platform ZABBIX version...

Five ways to traverse JavaScript arrays

Table of contents 1. for loop: basic and simple 2...

Javascript File and Blob Detailed Explanation

Table of contents File() grammar parameter Exampl...

Example of automatic stop effect after text scrolling

The effect is very simple, just copy the following...

Implementation of MySQL's MVCC multi-version concurrency control

1 What is MVCC The full name of MVCC is: Multiver...

Native js to implement a simple calculator

This article example shares the specific code of ...

Pure CSS to achieve cloudy weather icon effect

Effect The effect is as follows ​ Implementation ...

How to configure eureka in docker

eureka: 1. Build a JDK image Start the eureka con...

A small introduction to the use of position in HTML

I just learned some html yesterday, and I couldn&#...

An IE crash bug

Copy code The code is as follows: <style type=...

How to connect to virtual machine MySQL using VScode in window environment

1. Virtual Machine Side 1. Find the mysql configu...

Detailed explanation of how to use Tomcat Native to improve Tomcat IO efficiency

Table of contents Introduction How to connect to ...

SQL query for users who have placed orders for at least seven consecutive days

Create a table create table order(id varchar(10),...