欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CSS中的clip-path區(qū)域裁剪屬性使用教程

Haorooms   發(fā)布時(shí)間:2016-06-28 11:44:45   作者:Aaron   我要評(píng)論
clip-path能根據(jù)設(shè)定的大小將頁面的元素劃分出所要顯示的區(qū)域,或者說相當(dāng)于遮罩而不是真正地裁去某個(gè)部分,這里我們就來看一下CSS中的clip-path區(qū)域裁剪屬性使用教程

CSS中的clip-path能夠讓你指定一個(gè)網(wǎng)頁元素的顯示區(qū)域,而不是缺省的顯示全部。

CSS Code復(fù)制內(nèi)容到剪貼板
  1. .clip-me {     
  2.      
  3.   /* 已被標(biāo)志為不推薦使用的寫法 */  
  4.   positionabsolute/* 需要 absolute 和 fixed 定位 */  
  5.   clip: rect(110px160px170px60px); /* 或 "auto" */  
  6.   /* 值描述的是一個(gè) top/left 點(diǎn)和一個(gè) bottom/right 點(diǎn) */  
  7.   
  8.   /* 最新規(guī)范寫法 (沒有定位要求), */  
  9.   clip-path: inset(10px 20px 30px 40px); /* or "none" */  
  10.   /* 值指的是 top, right, bottom, left 四個(gè)點(diǎn) */  
  11.   
  12.   
  13. }  

在clip-path的屬性值中的inset()函數(shù)中有四個(gè)值,分別表達(dá)著top/left和bottom/right四個(gè)點(diǎn),圈出一個(gè)矩形面積。這個(gè)矩形面積外的部分都將被裁剪隱藏掉。

需要注意的是,數(shù)值中間是用空格分割的,而老式的是用逗號(hào)。
2016628114452083.jpeg (680×300)

例子:
2016628114534010.png (349×327)

看這個(gè)效果,對(duì)這個(gè)DIV進(jìn)行了裁剪。

代碼如下:

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <div class="haorooms-small" style="background-image: url('http://sandbox.runjs.cn/uploads/rs/216/0y89gzo2/idtga8h3.png');">  
  2.   </div>  
CSS Code復(fù)制內(nèi)容到剪貼板
  1. .haorooms-small {   
  2.     background-size: cover;   
  3.     width300px;   
  4.     height300px;   
  5.     -webkit-clip-path: polygon(0% 50%, 25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%);   
  6.     clip-path: polygon(0% 50%, 25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%);   
  7. }  

clip-path的inset屬性應(yīng)用

CSS Code復(fù)制內(nèi)容到剪貼板
  1. <img class="clip-me" src="thing-to-be-clipped.png">   
  2. .clip-me {     
  3.   /* 最新規(guī)范寫法 (沒有定位要求), */  
  4.   clip-path: inset(10px 20px 30px 40px); /* or "none" */  
  5.   /* 值指的是 top, right, bottom, left 四個(gè)點(diǎn) */  
  6. }  

在clip-path的屬性值中的inset()函數(shù)中有四個(gè)值,分別表達(dá)著top/left和bottom/right四個(gè)點(diǎn),圈出一個(gè)矩形面積。這個(gè)矩形面積外的部分都將被裁剪隱藏掉。

clip-path的其他屬性應(yīng)用

CSS Code復(fù)制內(nèi)容到剪貼板
  1. .clip-me {    
  2.   
  3.   /* 引用一個(gè)內(nèi)聯(lián)的 SVG <clipPath> 路徑*/  
  4.   clip-path: url(#c1);    
  5.   
  6.   /* 引用一個(gè)外部的 SVG  路徑*/  
  7.   clip-path: url(path.svg#c1);   
  8.   
  9.   /* 多邊形 */  
  10.   clip-path: polygon(5% 5%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);   
  11.   
  12.   /* 圓形 */  
  13.   clip-path: circle(30px at 35px 35px);   
  14.   
  15.   /* 橢圓 */  
  16.   clip-path: ellipse(65px 30px at 125px 40px);   
  17.   
  18.   /* inset-rectangle() 將會(huì)替代 inset() ? */  
  19.   /* rectangle() 有可能出現(xiàn)于 SVG 2 */  
  20.   
  21.   /* 圓角 */  
  22.   clip-path: inset(10% 10% 10% 10% round 20%, 20%);   
  23.   
  24. }  

SVG 裁剪路徑樣例:

CSS Code復(fù)制內(nèi)容到剪貼板
  1. <clipPath id="clipping">   
  2.   <circle cx="150" cy="150" r="50" />   
  3.   <rect x="150" y="150" width="100" height="100" />   
  4. </clipPath>  

相關(guān)文章

  • CSS中clip-path屬性的使用詳解

    這篇文章主要介紹了CSS中clip-path屬性的使用詳解,clip-path屬性可以創(chuàng)建一個(gè)只有元素的部分區(qū)域可以顯示的剪切區(qū)域。非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2018-10-16

最新評(píng)論