css3 新屬性 clip-path

clip-path 屬性使用裁剪方式創(chuàng)建元素的可顯示區(qū)域。區(qū)域內(nèi)的部分顯示,區(qū)域外的隱藏??梢灾付ㄒ恍┨囟ㄐ螤?。

1.clip-path: polygon(x y,x y,x y,x y); 多邊形裁剪

這里的x y 別是坐標(biāo)點(diǎn) (0 0)是元素的左上角頂點(diǎn)

image.png
例子:
//css:部分
.box1{
            width: 300px;
            height: 300px;
            background-color: #fd79a8;
            clip-path: polygon(0 50%,50% 100%,50% 0%);
        }
// html部分:
<div class="box1"></div>

效果


image.png

2. clip-path: circle(r at x y);圓形裁剪

這里的 r 是裁剪的半徑,x y 為圓心坐標(biāo)

例子:
// css 部分
.box2{
       width: 300px;
       height: 300px;
       background-color: #fd79a8;
       clip-path: circle(50% at 50% 50%);
    }
// html部分
<div class="box2"></div>

效果


image.png

3.ellipse(xr yr at x y); 橢圓形裁剪

這里的 xr 是橢圓x軸半徑 yr 是y軸半徑,x y 為圓心坐標(biāo)

例子:
// css部分
.box3{
        width: 300px;
        height: 300px;
        background-color: #fd79a8;
        clip-path: ellipse(50% 20% at 50% 50%);
     }
// html部分
<div class="box3"></div>

效果


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容