Teach you how to use css3 to add gradient effects to images (detailed code explanation)

奋力向前
Release: 2021-08-17 10:36:41
forward
4906 people have browsed it

In the previous article "Teach you step by step how to use CSS3 to achieve animation effects (code sharing)", I will introduce to you how to use CSS3 animation effect setting experience. The following article will introduce to you how to use css3 to add gradient effects to images. Let’s take a look.

Teach you how to use css3 to add gradient effects to images (detailed code explanation)

The first time I came into contact with css3 gradient was a long time ago. I thought this thing was very interesting. It is like playing PS and you can make many gorgeous things.

Browser support

IE FF Chrome Safari Opera iOS Android Android Chrome
6-9(no) 2-3.5(no) 4-9(part-webkit-) 3.1-3.2(no) - 3.2-4.3(Part) 2.1-3.0(-webkit-) 10-25(-webkit-)
10 3.6-15(-webkit-) 10-25(-webkit-) 4-5(part)5-6.1(-webkit-) - 5 4-4.3(-webkit-) 26
- 15 25 5-6 15 - 4.4 -

linear-gradient linear-gradient

Use syntax

linear-gradient([ [ [| to [top | bottom] || [left | right] ],]?[,]+);
Copy after login

The following codes can be run, and the execution results are the same

linear-gradient(#fff, #333); linear-gradient(to bottom, #fff, #333); linear-gradient(to top, #333, #fff); linear-gradient(180deg, #fff, #333); linear-gradient(to bottom, #fff 0%, #333 100%);
Copy after login

You can define the angle, starting direction, color, and color proportion

demo

Copy after login

Teach you how to use css3 to add gradient effects to images (detailed code explanation)

##Fill the test line The usage of gradient repeating-linear-gradient

is similar to that of linear-gradient. It is actually a filling of the gradient. It can be accurate to pixels, such as realizing a zebra pattern

Copy after login

Teach you how to use css3 to add gradient effects to images (detailed code explanation)

radial gradientradial-gradient

Use syntax

radial-gradient( [ circle ||][ at]? , | [ ellipse || [|]{2}][ at]? , | [ [ circle | ellipse ] ||][ at]? , | at,[ ,]+ )
Copy after login

The following code execution results are the same

radial-gradient(circle, #f00, #ff0, #080); radial-gradient(circle at center, #f00, #ff0, #080); radial-gradient(circle at 50%, #f00, #ff0, #080); radial-gradient(circle farthest-corner, #f00, #ff0, #080);
Copy after login

You can quickly locate the position of the shape throughlengthclosest-side The edge shape of the gradient and the container are closest to the gradient center point is tangent to one side (circle) or at least to the vertical and horizontal sides closest to the center point of the gradient (ellipse).

closest-corner The edge shape of the gradient intersects the corner of the container closest to the center point of the gradient.

farthest-side The opposite of closest-side, the edge shape is tangent to the side of the container farthest from the center point of the gradient (or the furthest vertical and horizontal sides).

farthest-corner The edge shape of the gradient intersects the corner of the container farthest from the center point of the gradient.

You can useatto quickly determine the position of the center of the circlecircle at left topThe center of the circle is in the upper left corner

  • circle at right top circle center at the upper right corner

  • circle at left bottom circle center at the lower left corner

  • circle at right bottom The center of the circle is in the lower right corner

  • ##circle at center | at 50% The center of the circle is in the middle
  • Code example
 
Copy after login

Get the following

Teach you how to use css3 to add gradient effects to images (detailed code explanation)Filled radial gradient repeating-radial-gradient

This is similar to repeating-linear-gradient, which is to fill in the gradient.

Code example

 
Copy after login

Get the following

Teach you how to use css3 to add gradient effects to images (detailed code explanation)You can use gradients to create many effects

Code example

Copy after login
   
Copy after login

As shown below, you can make a beautiful bubble

Teach you how to use css3 to add gradient effects to images (detailed code explanation)and then use the animation from the previous article to make it move.

Click here to see the effect https://k-ui.cn The animation is delayed and will take a while to appear.

Recommended learning:

CSS3 video tutorial

The above is the detailed content of Teach you how to use css3 to add gradient effects to images (detailed code explanation). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:chuchur.com
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!