标签:osi 浏览器 -- body url 背景图 需求 pre enter
<body> <div> <!--背景图片--> <div id="web_bg" style="background-image: url(./img/bg.jpg);"></div> <!--其他代码 ... --> </div> </body>
以上是需求代码
以下是实现css样式代码
#web_bg{ position:fixed; top: 0; left: 0; width:100%; height:100%; min-width: 1000px; z-index:-10; zoom: 1; background-color: #fff; background-repeat: no-repeat; background-size: cover; -webkit-background-size: cover; -o-background-size: cover; background-position: center 0; }
通过以上操作,我们可以实现将一张图片作为网页背景,且不会因为浏览器的尺寸导致留白和重复
标签:osi 浏览器 -- body url 背景图 需求 pre enter
原文地址:https://www.cnblogs.com/dongxixi/p/11001225.html