Before CSS3, gradient images could only be used as background images Color value RGBA The RGB color standard we are familiar with is composed of three colors: r (red), g (green), and b (blue) to form various colors with values of 0~255, or 0~100%. RGBA adds an alpha opacity parameter to RGB. Example 1: Normal red RGB color .demo { width: 100px; height: 100px; background-color: rgb(255, 0, 0); } Example 2: Using RGBA to create a red translucent effect .demo { width: 100px; height: 100px; background-color: rgba(255, 0, 0, 0.5); }
Linear-gradient Gradient means "inclination", linear means "linear". Gradient color is a smooth transition between multiple colors to form a gorgeous color. The linear-gradient parameters include the direction of the gradient (optional) and any number of gradient colors. Example 3: Red, green and blue gradient colors .demo { width: 100px; height: 100px; background: linear-gradient(red,lime,blue); } Note that I wrote background here, not background-color If the gradient direction is not filled in, it defaults to being from top to bottom. The gradient direction has the following property values .demo { width: 100px; height: 100px; background: linear-gradient(to top left,red,lime,blue); } Angle 0deg is equivalent to to top, increasing the angle is equivalent to rotating clockwise .demo { width: 100px; height: 100px; background: linear-gradient(20deg,red,lime,blue); } You can add the position of each color gradient after each color .demo { width: 100px; height: 100px; background: linear-gradient(red 30%,lime 50%,blue 70%); } If you don't fill it in, the browser will divide it equally by default. For example, the three color values are 0%, 50%, and 100% by default. There is also an unusual function repeating-linear-gradient that allows us to repeat the linear gradient .demo { width: 100px; height: 100px; background: repeating-linear-gradient(red, rgba(100,100,100,0.5),blue 50%); } The result is this ugly gradient color. radial-gradient radial means "radial, radiating" .demo { width: 200px; height: 100px; background: radial-gradient(red,lime,blue); } Similar to linear gradient, but the first parameter (optional) is the gradient shape of radial gradient. The position can be circle or ellipse (default). .demo { width: 200px; height: 100px; background: radial-gradient(circle,red,lime,blue); } You can use the shape at position format to define the position of the gradient center. .demo { width: 200px; height: 100px; background: radial-gradient(circle at 30% 30%,red,lime,blue); } The gradient position can be expressed in percentage or pixel form. If only one value is entered, the other value defaults to the middle position 50%. .demo { width: 200px; height: 100px; background: radial-gradient(circle at 30%,red,lime,blue); } If you don't want to use keywords, you can also use numbers for gradient sizes. .demo { width: 200px; height: 100px; background: radial-gradient(100px 100px at 50px 50px,red,lime,blue); } Indicates gradient size 100px*100px, gradient position 50px*50px Radial gradient also has a repeated gradient function, which is similar to linear gradient. I won't explain it here. .demo { width: 200px; height: 100px; background: repeating-radial-gradient(red 10%,lime 20%,blue 30%); } This is the end of this article about the use of CSS3 color value RGBA and gradient colors. For more relevant CSS3 RGBA and gradient color content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! |
<<: WeChat applet uniapp realizes the left swipe to delete effect (complete code)
>>: Steps of an excellent registration process
1. Delete file command: find the corresponding di...
This article example shares the specific implemen...
Introduction to border properties border property...
The GROUP BY statement is used in conjunction wit...
one. Overview of IE8 Compatibility View <br /&...
1. Abnormal performance of Docker startup: 1. The...
After installing the MySQL database using the rpm...
1: Define a stored procedure to separate strings ...
The problems and solutions encountered when deplo...
Canal is an open source project under Alibaba, de...
There are many tags in XHTML, but only a few are ...
Table of contents Project Introduction: Project D...
The commonly used Oracle10g partitions are: range...
Table of contents 1. v-for: traverse array conten...
The function to be implemented today is the follo...