執行個體講解CSS3 mask的具體使用方法

來源:互聯網
上載者:User
css的mask屬性允許使用者通過部分或者完全隱藏一個元素的可見地區。這種效果可以通過遮罩或者裁切特定地區的圖片。本文主要介紹了CSS3 mask 遮罩的具體使用方法,詳細的介紹了CSS3 mask 遮罩的具體使用,具有一定的參考價值,有興趣的可以瞭解一下,希望能協助到大家。

mask的簡寫會將 mask-border 設為初始值。使用mask的簡寫優於其他簡寫或者各自屬性的設定來覆蓋。這能保證mask-border也會重新設定為新的效果樣式。

mask-image

mask-image 通過讀取透明度對html元素進行遮罩,黑色代表透明,白色代表不透明,灰色為半透明。適用於所有元素,在SVG中,它作用於包含<defs>元素和所有圖形元素的容器。


/* 圖片資源 */-webkit-mask-image: url(mask.png);/* css的漸層屬性 */ -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0)); /* image屬性 ~ ??? */-webkit-mask-image: image(url(mask.png), skyblue);/* 混合屬性 */-webkit-mask-image: url('http://d.lanrentuku.com/down/png/1410/bw_halloween/bat-3-256.png'), linear-gradient(rgba(0, 0, 0, 1.0), transparent);

mask-repeat


/* 單個值 */-webkit-mask-repeat: no-repeat | repeat-x | repeat-y | space | round | repeat(預設值);/* 兩個值 horizontal(水平)  vertical(垂直) (以下僅為樣本)*/-webkit-mask-repeat: repeat space | repeat repeat | round space | no-repeat round;/* Multiple values */-webkit-mask-repeat: space round, no-repeat;-webkit-mask-repeat: round repeat, space, repeat-x;/* 多層遮罩  (。・_・)/~~~*/mask-image: url('mask1.png'), url('mask2.png');mask-repeat: repeat-x, repeat-y;

mask-clip


-webkit-mask-clip: content-box | padding-box | border-box | margin-box | fill-box | stroke-box | view-box | no-clip;-webkit-mask-clip: border;-webkit-mask-clip: padding;-webkit-mask-clip: content;-webkit-mask-clip: text;/* Multiple values */-webkit-mask-clip: padding-box, no-clip;-webkit-mask-clip: view-box, fill-box, border-box;

mask-origin


/* Keyword values */mask-origin: content-box;mask-origin: padding-box;mask-origin: border-box;mask-origin: margin-box;mask-origin: fill-box;mask-origin: stroke-box;mask-origin: view-box;/* Multiple values */mask-origin: padding-box, content-box;mask-origin: view-box, fill-box, border-box;/* Non-standard keyword values */ -webkit-mask-origin: content; -webkit-mask-origin: padding; -webkit-mask-origin: border;

mask-size


.pTest{    padding: 40px;    background-color: #03ff36;    background-image: url(http://cdn01.baidu-img.cn/timg?image_search&quality=80&size=b10000_10000&sec=1470644878&di=f054ab9449175833cf84b3429acacd88&imgtype=jpg&src=http%3A%2F%2Fimg0.bdstatic.com%2Fimg%2Fimage%2Fshouye%2Fxiaoxiao%2Fis099s8ky-PC.jpg));    -webkit-mask-image: url(http://image27.360doc.com/DownloadImg/2011/04/2015/11077777_58.png)), url(http://img.t.sinajs.cn/t6/style/images/global_nav/WB_logo.png));    -webkit-mask-repeat: space,repeat-y;    -webkit-mask-clip: text;     -webkit-mask-size: 5%, 8%;    border: 30px solid red;}

mask-composite (均不支援 ಥ _ ಥ )


mask-composite: add | subtract | intersect | exclude;
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.