首頁  >  文章  >  web前端  >  詳解CSS3背景相關樣式實例代碼

詳解CSS3背景相關樣式實例代碼

高洛峰
高洛峰原創
2017-03-16 09:47:542045瀏覽

這篇文章詳解CSS3背景相關樣式實例代碼

background-image#繪製多張圖片疊加,範例如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>background-image绘制多张图片叠加</title>
    <style>
        div{
            width:1100px;
            height:800px;
            background-image: url("../../image/icon1.jpg"),url("../../image/border3.jpg");
            background-repeat: repeat-x,no-repeat ;
            background-position:100%,100%,center,center;
            border:5px solid #ff0000;
        }
    </style>
</head>
<body>
<div></div>
</body>
</html>

background-clip:規定背景的繪製區域:
background-origin:相對於內容框來定位背景圖片:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>background-clip及background-origin属性</title>
    <style>
        /*background-clip:规定背景的绘制区域:*/
        /*background-origin:相对于内容框来定位背景图像:*/
        div{
            background: #fff000;
            font-size: 30px;
            border:10px dashed #0000ff;
            padding:20px;
            background-image: url("../../image/icon.png");
            background-repeat:no-repeat;
        }
        .div2{
            margin-top:30px;
            background-origin: content-box;
            background-clip: content-box;
        }
        .div3{
            margin-top:30px;
            background-origin: border-box;
            background-clip: border-box;
        }
        .div4{
            margin-top:30px;
            background-origin: padding-box;
            background-clip: padding-box;
        }
    </style>
</head>
<body>
<div>这是一段测试文字</div>
<div>这是一段测试文字</div>
<div>这是一段测试文字</div>
<div>这是一段测试文字</div>
</body>
</html>

 css3的box-shadow屬性:#​​

##讓ie6、7、8都支援border-radius 、box-shadow、

text-shadow的方法:用ie-css3.htc

先下載ie-css3.htc腳本,然後在css中加入:


它的使用方法是:下載它並放到你的伺服器目錄

在你的93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1裡面寫入下面的程式碼:

.box{
-moz-box-shadow: 10px 10px 20px #000; /* Firefox */ 
-webkit-box-shadow: 10px 10px 20px #000; /* Safari and Chrome */ 
box-shadow: 10px 10px 20px #000; /* Opera 10.5+, future browsers and IE6+ using IE-CSS3 */ 
behavior: url(ie-css3.htc); 
}

注意:behavior: url(ie-css3.htc) 中的ie-css3. htc位址用絕對路徑或直接傳到網站的根目錄下面,不然可能會看不到效果。

•當你使用了這個htc檔案後,你的CSS裡面,只要寫有box-shadow, -moz-box-shadow或-webkit-box-shadow的任何一種,IE就會渲染。

•當使用了這個htc檔案後,你不能這樣寫box-shadow: 0 0 10px red; 而應該是box-shadow: 0px 0px 10px red; 否則IE中會失效。
•不支援RGBA值中的alpha透明度。
•不支援inset內陰影。
•不支援陰影擴充。
•陰影在IE中只會顯示為黑色,不管你設定成
其它什麼顏色。 但是,這個腳本了只是讓IE支援了部份的box-shadow值。

以上是詳解CSS3背景相關樣式實例代碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn