溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

clip-path屬性怎么在CSS中使用

發(fā)布時間:2021-03-26 15:40:53 來源:億速云 閱讀:154 作者:Leah 欄目:web開發(fā)

clip-path屬性怎么在CSS中使用?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

clip-path的使用

polygon

  • 值為多個坐標點組成,坐標第一個值是x方向,第二個值是y方向。

  • 左上角為原點,右下角是(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>值為多個坐標點組成,坐標第一個值是x方向,第二個值是y方向。</p>
  <p>左上角為原點,右下角是(100%,100%)的點。</p>
  <div class="polygon1"></div>
  <div class="polygon2"></div>
  <div class="polygon3"></div>
</div>

clip-path屬性怎么在CSS中使用

circle

  • 值為一個坐標點和半徑組成。

  • 左上角為原點,右下角是(100%,100%)的點。

  • 定義半徑的時候可以用at關(guān)鍵字來定義坐標。

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>值為一個坐標點和半徑組成。</p>
  <p>左上角為原點,右下角是(100%,100%)的點。</p>
  <p>定義半徑的時候可以用at關(guān)鍵字來定義坐標。</p>
  <div class="circle1"></div>
  <div class="circle2"></div>
  <div class="circle3"></div>
</div>

clip-path屬性怎么在CSS中使用

ellipse

  • 值為橢圓的x軸半徑,y軸半徑,定位橢圓的坐標三部分組成。

  • 左上角為原點,右下角是(100%,100%)的點。

  • at關(guān)鍵字將半徑和坐標分開。

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>值為橢圓的x軸半徑,y軸半徑,定位橢圓的坐標三部分組成。</p>
  <p>左上角為原點,右下角是(100%,100%)的點。</p>
  <p>at關(guān)鍵字將半徑和坐標分開</p>
  <div class="ellipse1"></div>
  <div class="ellipse2"></div>
  <div class="ellipse3"></div>
</div>

clip-path屬性怎么在CSS中使用

inset

值為(上 右 下 左 round 左上角radius 右上角radius 右下角radius 左下角radius)

round前面的數(shù)值,表示的是距離,如果第一個值為25%,則表示圖像在上面從25%開始繪制。

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>值為(上 右 下 左 round 左上角radius 右上角radius 右下角radius 左下角radius)</p>
  <p>round前面的數(shù)值,表示的是距離,如果第一個值為25%,則表示圖像在上面從25%開始繪制</p>
  <div class="inset1"></div>
  <div class="inset2"></div>
  <div class="inset3"></div>
</div>

clip-path屬性怎么在CSS中使用

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI