?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
background-clip:<box> [ , <box> ]*
<box> = border-box | padding-box | content-box | text
默認(rèn)值:border-box
適用于:所有元素
繼承性:無
動畫性:否
計算值:指定值
padding-box:
從padding區(qū)域(不含padding)開始向外裁剪背景。
border-box:
從border區(qū)域(不含border)開始向外裁剪背景。
content-box:
從content區(qū)域開始向外裁剪背景。
text:
從前景內(nèi)容的形狀(比如文字)作為裁剪區(qū)域向外裁剪,如此即可實(shí)現(xiàn)使用背景作為填充色之類的遮罩效果。遮罩效果 See with Webkit
對應(yīng)的腳本特性為backgroundClip。
Values | IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
---|---|---|---|---|---|---|---|---|
Basic Support | 6.0-8.0 | 2.0-3.5 | 4.0+ | 6.0+ | 15.0+ | 6.0+ | 2.1-2.3 -webkit- | 18.0+ |
9.0+ | 3.6 -moz- | 3.0+ | ||||||
4.0+ | ||||||||
text #1 | 6.0-11.0 | 2.0-38.0 |
text屬性值,目前為webkit only [1] [2]。
<!DOCTYPE html> <html lang="zh-cmn-Hans"> <head> <meta charset="utf-8" /> <title>background-clip_CSS參考手冊_web前端開發(fā)參考手冊系列</title> <meta name="author" content="Joy Du(飄零霧雨), dooyoe@gmail.com, www.doyoe.com" /> <style> h1{font-size:20px;} h2{font-size:16px;} p{width:200px;height:200px;margin:0;padding:20px;border:10px dashed #666;background:#aaa url(skin/p_103x196_1.jpg) no-repeat;} .border-box p{background-clip:border-box;} .padding-box p{background-clip:padding-box;} .content-box p{background-clip:content-box;} .text p{width:auto;height:auto;background-repeat:repeat;-webkit-background-clip:text;-webkit-text-fill-color:transparent;font-weight:bold;font-size:120px;} </style> </head> <body> <h1>background-clip</h1> <ul class="test"> <li class="border-box"> <h2>border-box</h2> <p>從border區(qū)域(不含border)開始向外裁剪背景</p> </li> <li class="padding-box"> <h2>padding-box</h2> <p>從padding區(qū)域(不含padding)開始向外裁剪背景</p> </li> <li class="content-box"> <h2>content-box</h2> <p>從content區(qū)域開始向外裁剪背景</p> </li> <li class="text"> <h2>text</h2> <p>從前景內(nèi)容的形狀作為裁剪區(qū)域向外裁剪背景</p> </li> </ul> </body> </html>
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例