给网页设置全屏背景图片

2018-09-17  本文已影响8人  守星的犬

首先设置页面宽高

html,body{
    width:100%;
    height:100%
}

添加设置背景图

body{
  width:100%;
  height:100%;
  background-size: cover;
  position:absolute; 
  background-image: url('../../assets/images/bg.jpg');
  background-position:50% 50%;
  background-repeat :no-repeat;
  background-attachment:fixed;
}

搞定。

上一篇 下一篇

猜你喜欢

热点阅读