这篇文章详解CSS3背景相关样式实例代码
background-image绘制多张图片叠加,示例如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!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:相对于内容框来定位背景图像:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>background-clip及background-origin属性</title>
<style>
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中加入:
它的使用方法是:下载它并放到你的服务器目录
在你的<head></head>里面写入下面的代码:
1 2 3 4 5 6 | .box{
-moz-box-shadow: 10px 10px 20px #000;
-webkit-box-shadow: 10px 10px 20px #000;
box-shadow: 10px 10px 20px #000;
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中文网其他相关文章!