# CSS设置背景图片

# 1. 背景图设置

    body{
            background-image: url(bg.jpg);
            background-size: 100% 100%;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }
  • background-image:背景图片
  • background-size: 背景尺寸
  • background-repeat: 背景图是否重复
  • background-attachment:背景是否滚动

简写

 background: url(bg.jpg) 100% no-repeat;