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

詳解css中background-clip屬性的作用

  發(fā)布時(shí)間:2018-03-29 14:26:25   作者:佚名   我要評(píng)論
這篇文章主要介紹了css中background-clip屬性的作用,background-clip屬性的通俗作用就是指定元素背景所在的區(qū)域,對(duì)css中background-clip屬性的相關(guān)知識(shí)感興趣的朋友一起看看吧

background-clip屬性的通俗作用就是指定元素背景所在的區(qū)域,有四種取值

1、border-box

border-box是默認(rèn)值,表示元素的背景從border區(qū)域(包括border)以內(nèi)開始保留背景。

簡(jiǎn)單代碼如下:

<!doctype html>
<html>
    <head>
        <style>
        *{margin:0;padding:0;} 
            .box{width:380px;height:280px;margin:100px auto;background:url("1.jpg") no-repeat -5px;padding:5px;border:5px dotted #000;<br>       background-clip:border-box;}
        </style>
   </head>
   <body>
       <div class="box"></div>
   </body>
</html> 

效果如下:

  

從上圖我們可以看出,元素背景默認(rèn)是存在于邊框及以內(nèi)的區(qū)域,但是不知道為什么加背景圖片,不能全部覆蓋;而背景顏色則沒沒這個(gè)問題。

2、padding-box

padding-box表示元素的背景從padding區(qū)域(包括padding)以內(nèi)開始保留。

簡(jiǎn)單代碼如下:
 

<!doctype html>
<html>
    <head>
        <style>
        *{margin:0;padding:0;} 
            .box{width:380px;height:280px;margin:100px auto;background:url("1.jpg") no-repeat -5px;padding:5px;border:5px dotted #000;<br>            background-clip:padding-box;}
        </style>
   </head>
   <body>
       <div class="box"></div>
   </body>
</html>

效果如下:

從上圖我們可以看出背景圖片存在于padding及以內(nèi)區(qū)域。

3、content-box

content-box表示元素的背景從內(nèi)容區(qū)域以內(nèi)開始保留。

簡(jiǎn)單代碼如下:

<!doctype html>
<html>
    <head>
        <style>
        *{margin:0;padding:0;} 
            .box{width:380px;height:280px;margin:100px auto;background:url("1.jpg") no-repeat -5px;padding:5px;border:5px dotted #000;<br>            background-clip:content-box;}
        </style>
   </head>
   <body>
       <div class="box"></div>
   </body>
</html>

效果如下:

從上圖我們可以看出背景圖片存在于內(nèi)容區(qū)域以內(nèi)。

4、text

content-box表示元素的背景保留在前景內(nèi)容中(文字),和其形狀大小相同,目前僅支持chrome瀏覽器

簡(jiǎn)單代碼如下:

<!doctype html>
<html>
    <head>
        <style>
        *{margin:0;padding:0;} 
            .box{width:380px;height:280px;margin:100px auto;background:red;padding:5px;border:5px dotted #000;<br>             font-size:100px;font-weight;bold;-webkit-background-clip:text;-webkit-text-fill-color:transparent;}
        </style>
   </head>
   <body>
       <div class="box">你 好 你 好</div>
   </body>
</html>

 效果如下:

說(shuō)明:目前值為text時(shí),兼容性極差,僅知道即可。

總結(jié)

以上所述是小編給大家介紹的詳解css中background-clip屬性的作用,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論