Detailed explanation of the use of the clip-path property in CSS

Detailed explanation of the use of the clip-path property in CSS

Use of clip-path

polygon

  • The value is composed of multiple coordinate points. The first value is in the x direction and the second value is in the y direction.
  • The upper left corner is the origin, and the lower right corner is the point (100%, 100%). </p>
body {
  background-color: #000;
}

.fa {
  border: 1px solid #fff;
  color:yellowgreen;
  padding: 10px;
  margin: 10px;
}

.fa>div {
  width: 110px;
  height: 110px;
  background-color: yellowgreen;
  margin: 20px auto;
}

.polygon1 {
  clip-path: polygon(50% 0px, 100% 100%, 0px 100%)
}

.polygon2 {
  clip-path: polygon(0px 50%, 50% 0, 100% 50%, 50% 100%)
}

.polygon3 {
  clip-path: polygon(0% 60%, 20% 0%, 60% 0%, 40% 60%)
}
<div class="fa">
  <p>polygon</p>
  <p>The value is composed of multiple coordinate points. The first value is in the x direction, and the second value is in the y direction. </p>
  <p>The upper left corner is the origin, and the lower right corner is the point (100%, 100%). </p>
  <div class="polygon1"></div>
  <div class="polygon2"></div>
  <div class="polygon3"></div>
</div> 

circle

  • The value consists of a coordinate point and a radius.
  • The upper left corner is the origin, and the lower right corner is the point (100%, 100%).
  • When defining the radius, you can use the at keyword to define the coordinates.
body {
  background-color: #000;
}

.fa {
  border: 1px solid #fff;
  color:yellowgreen;
  padding: 10px;
  margin: 10px;
}

.fa>div {
  width: 110px;
  height: 110px;
  background-color: yellowgreen;
  margin: 20px auto;
}

.circle1 {
  clip-path: circle(50% at 50% 50%)
}

.circle2 {
  clip-path: circle(70% at 50% 50%)
}

.circle3 {
  clip-path: circle(30% at 10% 10%)
}
<div class="fa">
  <p>circle</p>
  <p>The value consists of a coordinate point and a radius. </p>
  <p>The upper left corner is the origin, and the lower right corner is the point (100%, 100%). </p>
  <p>When defining the radius, you can use the at keyword to define the coordinates. </p>
  <div class="circle1"></div>
  <div class="circle2"></div>
  <div class="circle3"></div>
</div> 

ellipse

  • The value consists of the x-axis radius of the ellipse, the y-axis radius, and the coordinates of the positioning ellipse.
  • The upper left corner is the origin, and the lower right corner is the point (100%, 100%).
  • The at keyword separates the radius from the coordinates.
body {
  background-color: #000;
}

.fa {
  border: 1px solid #fff;
  color:yellowgreen;
  padding: 10px;
  margin: 10px;
}

.fa>div {
  width: 110px;
  height: 110px;
  background-color: yellowgreen;
  margin: 20px auto;
}

.ellipse1 {
  clip-path: ellipse(30% 20% at 50% 50%)
}

.ellipse2 {
  clip-path: ellipse(20% 30% at 50% 50%)
}

.ellipse3 {
  clip-path: ellipse(60% 10% at 10% 10%)
}
<div class="fa">
  <p>ellipse</p>
  <p>The value consists of the x-axis radius of the ellipse, the y-axis radius, and the coordinates of the positioning ellipse. </p>
  <p>The upper left corner is the origin, and the lower right corner is the point (100%, 100%). </p>
  <p>The at keyword separates the radius from the coordinates</p>
  <div class="ellipse1"></div>
  <div class="ellipse2"></div>
  <div class="ellipse3"></div>
</div>

inset

The value is (top right bottom left round top left radius top right radius bottom right radius bottom left radius)

The value before round represents the distance. If the first value is 25%, it means that the image is drawn starting from 25% on the top.

body {
  background-color: #000;
}

.fa {
  border: 1px solid #fff;
  color:yellowgreen;
  padding: 10px;
  margin: 10px;
}

.fa>div {
  width: 110px;
  height: 110px;
  background-color: yellowgreen;
  margin: 20px auto;
}

.inset1 {
  clip-path: inset(25% 0% 25% 0% round 0% 25% 0% 25%)
}

.inset2 {
  clip-path: inset(0% 25% 25% 0% round 25% 25% 25% 0%)
}

.inset3 {
  clip-path: inset(25% 25% 0% 0% round 0% 25% 0% 25%)
}
<div class="fa">
  <p>inset</p>
  <p>The value is (top right bottom left round top left radius top right radius bottom right radius bottom left radius)</p>
  <p>The value before round indicates the distance. If the first value is 25%, it means that the image is drawn starting from 25% on the top</p>
  <div class="inset1"></div>
  <div class="inset2"></div>
  <div class="inset3"></div>
</div> 

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  How to use cursor triggers in MySQL

>>:  Master the commonly used HTML tags for quoting content in web pages

Recommend

The viewport in the meta tag controls the device screen css

Copy code The code is as follows: <meta name=&...

jQuery realizes the picture following effect

This article shares the specific code of jQuery t...

Some key points of website visual design

From handicraft design to graphic design to web de...

What should I do if I want to cancel an incorrect MySQL command?

I typed a wrong mysql command and want to cancel ...

Summary of Docker Consul container service updates and issues found

Table of contents 1. Container service update and...

Two ways to achieve horizontal arrangement of ul and li using CSS

Because li is a block-level element and occupies ...

Linux redis-Sentinel configuration details

download Download address: https://redis.io/downl...

Configuring MySQL and Squel Pro on Mac

In response to the popularity of nodejs, we have ...

MariaDB under Linux starts with the root user (recommended)

Recently, due to the need to test security produc...

Detailed explanation of MySQL batch SQL insert performance optimization

For some systems with large amounts of data, the ...