首页 > 关于全屏背景更好的解决方法?

关于全屏背景更好的解决方法?

在项目中遇到网页全屏背景的问题?
我是这样解决的,不知有什么更好的方法?

<body>
<header></header>
<main></main>
<footer></footer>
<div class="body_bg">
  <img src="bg1.png" width="100%" height:"100%"></img>
</div>
<body>

.body_bg{
   position:absolute;
   left:0;
   right:0;
   bottom:0;
   top:0;
   z-index:-1
}

html {
    height: 100%;
}
body {
    min-height: 100%;
    background-image: url();
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
}

背景图足够大即可~


楼主这个方法目测是目前最好的,我也一直用的这种。
或者说通过JS算。。。


http://.com/q/1010000003769052/a-1020000003769745


如果把absolute定位换成fixed定位的话,那或许更赞……

或者呢,直接把background写到html标签里,更直接……


.body-big{width:100vw;height:100vh;min-width:1024px;min-height:600px;}
Img{width:100%;height:100%;}

【热门文章】
【热门文章】