css背景图片定位

背景图默认平铺:

background-repeat: no-repeat;/*不平铺*/
                              /*repeat-x;沿X轴平铺*/
                              /*repeat-x;沿Y轴平铺*/

背景图片定位:

background-position: 100px 30px;/* X轴 Y轴 */
                               /* 20% 20%; 百分比的方式 */
                               /* left|center|right top|center|bottom */

背景中scroll的设置:

background-attachment: fixed;/* 固定背景图片,随滚动条拉动时背景不变 */
                                             /* scroll 默认滚动 */

复合样式(简化单一样式):

background: #ccc url(.../jpg) no-repeat center top fixed;
                  /* 颜色 背景图 是否平铺 背景图定位 scroll设置 */

 

posted @ 2018-01-02 21:16  cjx_work  阅读(364)  评论(0编辑  收藏  举报