Can css3 linear gradient achieve triangles?

青灯夜游
Release: 2022-04-25 15:01:27
Original
1909 people have browsed it

css3 linear gradient can realize triangles; just create a 45-degree linear gradient and set the gradient color to two fixed colors, one is the color of the triangle and the other is a transparent color. The syntax "linear- gradient(45deg, color value, color value 50%, transparent color 50%, transparent color 100%)".

Can css3 linear gradient achieve triangles?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

In CSS3, there are many ways to implement triangles, one of which is to use linear gradients. Let’s give you a detailed introduction below.

Use linear gradientlinear-gradientThe principle of implementing a triangle is also very simple. We implement a45°gradient linear gradient:

div { width: 100px; height: 100px; background: linear-gradient(45deg, deeppink, yellowgreen); }
Copy after login

Can css3 linear gradient achieve triangles?

Let its color change from a gradient color to two fixed colors:

div { width: 100px; height: 100px; background: linear-gradient(45deg, deeppink, deeppink 50%, yellowgreen 50%, yellowgreen 100%); }
Copy after login

Can css3 linear gradient achieve triangles?

##And then make one of the colors transparent:

div { background: linear-gradient(45deg, deeppink, deeppink 50%, transparent 50%, transparent 100%); }
Copy after login

Can css3 linear gradient achieve triangles?

By rotating

rotateorscale, we can also get triangles of various angles and sizes:

     
Copy after login

Can css3 linear gradient achieve triangles?

(Learning video sharing:

css video tutorial,web front-end)

The above is the detailed content of Can css3 linear gradient achieve triangles?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 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!