看起来像 CSS - 唯一提到的技术 #2:http: //css-tricks.com/perfect-full-page-background-image/但事实并非如此。代码略有变化(高度和显示属性)
我尝试复制粘贴他们的html css,但是我无法让它工作。是否可能涉及一些javascript?
看起来像 CSS - 唯一提到的技术 #2:http: //css-tricks.com/perfect-full-page-background-image/但事实并非如此。代码略有变化(高度和显示属性)
我尝试复制粘贴他们的html css,但是我无法让它工作。是否可能涉及一些javascript?
它只是 CSS 没有 JavaScript 工作演示
CSS
.front-bg {
position: fixed;
width: 200%;
height: 200%;
left: -50%;
background: black;
}
.front-bg img {
display: block;
margin: auto;
min-width: 50%;
min-height: 50%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
HTML
<div class="front-bg"><image src="http://a0.twimg.com/a/1349296073/t1/img/front_page/city-balcony@2x.jpg" /></div>
试试这个,
html, body {
margin:0;
padding:0;
background-image:url(relative/path/to/image);
background-repeat:no-repeat;
background-attachment:fixed;
}
#container {
margin:0 auto;
width:900px; /* your fixed width */
}