CSS3 background
2017-08-12 21:45
316 查看
background多背景图片:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> #div1 {background: url(img/billiard.png),url(img/medal.png) ; background-size: 300px 300px; width: 300px;height: 300px; } </style> </head> <body> <div id="div1"> </div> </body> </html>
效果如图:
background-origin:
background-origin 属性规定背景图片的定位区域三个值:
padding-box:背景图片相对于内边距框来定位
border-box:背景图片相对于边框盒来定位
content-box:背景图片相对于内容框来定位
1.padding-box
<style type="text/css"> #div1 { border: 30px dotted #eee; padding:20px;width: 200px;height: 200px;background-image: url(img/trophy.png) ; background-repeat: no-repeat; background-size: 200px 200px; background-origin: padding-box; } </style>
效果如下图:这是从padding开始定位背景图片
2.border-box
<style type="text/css"> #div1 { border: 30px dotted #999; padding:20px;width: 200px;height: 200px;background-image: url(img/trophy.png) ; background-repeat: no-repeat; background-size: 200px 200px; background-origin: border-box; } </style>
背景效果如下:
3.content-box
<style type="text/css"> #div1 { border: 3px dotted #999; padding:20px;width: 200px;height: 200px;background-image: url(img/trophy.png) ; background-repeat: no-repeat; background-size: 200px 200px; background-origin: content-box; } </style>
background-clip
background-clip规定背景的绘制区域有三个属性值:
border-box:背景被裁减到边框盒
padding-box:背景被裁减到内边框距
content-box:背景被裁减到内容框
1.border-box
<style type="text/css"> #div1 { border: 30px dotted #999; padding:20px;width: 200px;height: 200px;background-image: url(img/trophy.png) ; background-repeat: no-repeat; background-size: 200px 200px; background-origin: border-box; background-clip: border-box; } </style>
效果图
2.padding-box
<style type="text/css"> #div1 { border: 30px dotted #999; padding:20px;width: 200px;height: 200px;background-image: url(img/trophy.png) ; background-repeat: no-repeat; background-size: 200px 200px; background-origin: border-box; background-clip: padding-box; } </style>
效果图:
3.content-box
<style type="text/css"> #div1 { border: 30px dotted #999; padding:20px;width: 200px;height: 200px;background-image: url(img/trophy.png) ; background-repeat: no-repeat; background-size: 200px 200px; background-origin: border-box; background-clip: content-box; } </style>
效果图:
相关文章推荐
- 【CSS3】background-size
- CSS3 Full Background Slider
- CSS3简明教程-3.1.CSS3背景之 绘制区域background-clip
- [CSS3] The different of Background-size between 'cover' and 'contain'
- 详解css3系列:background属性
- CSS3 Background-clip
- css3实现一个div设置多张背景图片及background-image属性
- CSS3 background新增属性用法
- 深入浅出CSS3:background-clip,background-origin和border-image教程
- CSS3---background-size
- CSS3之多背景background使用示例
- 前端设计师必知的background属性(有CSS3内容)
- css3的Background新属性
- CSS3中background-clip和background-origin的区别
- CSS3 background-clip 属性
- css3中的content字图片处理background
- 深入浅出CSS3:background-clip,background-origin和border-image教程
- 使用css3 background属性制作3D易拉罐效果
- CSS3——box-sizing\background-size\box-shadow
- css3 background-size 用法