mic*_*obg 12 css background width
在我的页面中有2-3个部分,具有100%的宽度和背景.当我在全屏幕上打开它时一切正常但是当屏幕小于960px(本节中的内容宽度)时,背景图像不是整个页面.右侧的底片隐藏在最短的时刻没有背景 - 它是白色的.你可以在这里看到我的意思:http://micobg.net/10th/
Jay*_*Jay 23
只需将background-size:100%样式添加到您应用的元素即可background-image.适用于Firefox,Safari和Opera.例如:
<style>
.divWithBgImage {
width: 100%;
height: 600px;
background-image: url(image.jpg);
background-repeat: no-repeat;
background-size: 100%; //propotional resize
/*
background-size: 100% 100%; //stretch resize
*/
}
</style>
<div class="divWithBgImage">
some contents
</div>
Run Code Online (Sandbox Code Playgroud)
至于到这个文章,你应该使用cover,以及:
html {
background: url(PATH_TO_IMAGE) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Run Code Online (Sandbox Code Playgroud)