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

MySQL installation tutorial under Windows with pictures and text

MySQL installation instructions MySQL is a relati...

MYSQL master-slave replication knowledge points summary

An optimization solution when a single MYSQL serv...

Web Design Tutorial (5): Web Visual Design

<br />Previous article: Web Design Tutorial ...

Implementation of MySQL5.7 mysqldump backup and recovery

MySQL backup Cold backup:停止服務進行備份,即停止數據庫的寫入Hot ba...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

Install centos7 virtual machine on win10

1. Download VMware Workstation 64 version https:/...

HTML+CSS to achieve simple navigation bar function

Without further ado, I'll go straight to the ...

CentOS8 installation tutorial of jdk8 / java8 (recommended)

Preface At first, I wanted to use wget to downloa...

Mysql multi-condition query statement with And keyword

MySQL multi-condition query with AND keyword. In ...

Best Practices for Developing Amap Applications with Vue

Table of contents Preface Asynchronous loading Pa...

Detailed explanation of MySQL database index

Table of contents 1. Introduction to MySQL Index ...