背景

来源:互联网 发布:js 图片无缝滑动轮播 编辑:程序博客网 时间:2024/04/28 00:38

1、简单背景:

(1)      图片:background: url(img/back.jpg) 20px 20px;

(2)      颜色:background: #ffff;

2、基本背景:

background-color:bisque;

background-image: url(img/back.jpg);

         /*repeat-x、repeat-y、repeat、no-repeat*/

          background-repeat: no-repeat;

         /*要求图片固定在浏览器一角或一侧时用fixed属性,否则默认scroll*/

          background-attachment: fixed;

         /*repeat-x时定位左右无效,repeat-y时定位上下无效,repeat时定位完全失效*/

         /*background-position:top right;*/

          background-position: left top  ;

3、新属性background-origin:

background-size:50px 40px;

         /*背景图片的原点位置,content-box,padding-box或border-box*/

background-repeat:no-repeat;

background-origin:border-box;

4、新属性background-clip:

背景图片的剪切,content-box,padding-box或border-box,在webkit内核下还有text属性

background-image:url(img/back.jpg) ;

/*不兼容ie8*/

background-size:90px 120px;

background-repeat:no-repeat;

background-clip:border-box;

5、新属性background-size:

         auto:原像素,

         90px120px:自定义像素,

         90px:根据这一像素,按原比例调整像素,

         50%:占div的比例;

cover:放大填充

contain:按原比例缩放到div,不够的留白

6、新属性多背景属性           background:background-image|background-position|background-size|background-repeat|background-attachment|background-clip|background-origin,*

0 0