我已經創建了十個啓動器,您可以view on JS Fiddle。
我用下面的示例HTML和CSS
HTML
<div id="example">
<h1>Example</h1>
<p>Example text followed by a horizontal rule
example text followed by a horizontal rule
example text followed by a horizontal rule.</p>
<hr>
<p>Example text followed by a horizontal rule
example text followed by a horizontal rule
example text followed by a horizontal rule.</p>
<hr>
</div>
CSS
#example {
width: 50%;
margin: 0 auto;
background-color: #FCFCFC;
}
#example hr {
width: 150%;
}
固定Pixed寬度
你可以得到一個相同的最終結果固定的像素寬度,但它更加煩瑣。
我已將您的示例分爲demonstrate this solution on JSFiddle。
根據您所提供的HTML,CSS的是:
body {
overflow-x: hidden;
}
.wrapper { /* Center the layout */
width:800px;
margin:0 auto;
}
.leftCol { /* Left column */
width:200px;
float:left;
background-color:#ccc;
margin:0;
}
.rightCol { /* Right column */
width:600px;
float:right;
background-color:#dadada;
margin:0;
}
hr {
/* Make the HR extend to the
right edge of the viewport,
outside of .rightCol*/
width: 200%;
}
@media only screen and (max-width: 800px) {
body {
overflow-x: auto;
}
hr {
width: 100%;
}
}
請注意,這個解決方案的最後部分使用媒體查詢重置值時,視口被調整低於800像素的在這一點上你確實想要允許水平滾動條。媒體查詢在某些較舊的瀏覽器中無法使用,因此您需要在您想要支持的瀏覽器中進行測試。最糟糕的情況是您的用戶無法在舊版瀏覽器中水平滾動。
你能設置一個[jsfiddle](http://jsfiddle.net),它儘可能地接近你想要的效果嗎?一定要取消選中「規範化CSS」框。 – 2012-02-27 23:50:31
p.s.你是如何製作你美麗的模型的? – paislee 2012-02-28 00:10:54
當然,jsfiddle樣機在這裏: http://jsfiddle.net/ericcarl/3fQKe/ 和paislee,模型圖像剛剛放在一起使用Photoshop。很高興你挖! – 2012-02-28 00:17:52