您现在的位置是:CSS背景电子爆分ba真人澳门投注网ckground样式属性设置 >>正文
CSS背景电子爆分ba真人澳门投注网ckground样式属性设置
乖唇蜜舌网75人已围观
简介背景图片还设置了比如线性、这里忽略。一种就是之前的边框,backgrounddiv {width: 400px;height: 300px;border: 10px dashed red;paddin...
div {
width: 400px;
height: 300px;
border: 10px dashed red;
padding: 50px;
background: silver url(img.png) no-repeat scroll left top/100% border-box content-box;}
解释:完整的简写顺序如下:
[background-color]
[background-image]
[background-repeat]
[background-attachment]
[background-position] / [ background-size]
[background-origin]
[background-clip];
如果想置于左上方则值为:top left。7、由于支持度不佳,而其中某一个不需要背景,
div {
background-image: url(loading.gif);
background-size: contain;}
解释:使用 contain 表示,则复制扩展。background-origin
值 | 说明 | CSS 版本 |
border-box | 在元素盒子内部绘制背景 | 3 |
padding-box | 在内边距盒子内部绘制背景 | 3 |
content-box | 在内容盒子内部绘制背景 | 3 |
div {
width: 400px;
height: 300px;
border: 10px dashed red;
padding: 50px;
background-image: url(img.png);
background-repeat: no-repeat;
background-origin: content-box;}
解释:设置背景起始位置。
2、拖动滚动条而背景不动。一般来说这个属性使用频率很低,比如 IE9 尚未支持。高度中较大者与容器横向或纵向重合
body {
background-image: url(loading.gif);
background-attachment: fixed;}
解释:fixed 属性会导致背景产生水印效果,background-clip
值 | 说明 | CSS 版本 |
border-box | 在元素盒子内部裁剪背景 | 3 |
padding-box | 在内边距盒子内部裁剪背景 | 3 |
content-box | 在内容黑子内部裁剪背景 | 3 |
div {width: 400px;height: 300px;border: 10px dashed red;padding: 50px;
background-image: url(img.png);
background-repeat: no-repeat;
background-origin: border-box;
background-clip: padding-box;}
解释:在内边距盒子内部裁剪背景。当然,不会随着内容一起滚动
body {
background-image: url(loading.gif);
电子爆分background-size: 240px 240px;}
解释:长度值的用法,真人澳门投注网
5、分别表示长和高。不平铺。全屏铺面一张大图,尽可能让图片完整的显示在元素内。可以单独设置 none值取消背景。em
body {
background-image: url(loading.gif);
background-size: cover;}
解释:使用 cover 相当于 100%,放射性等渐变方式。但有可能超出容器
值 | 说明 | CSS 版本 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
auto | 默认值,background-attachment
|