[英]How can I get divs inside a div to continue on a new row when the current row (screen horizontally) is full?
[英]How can I get the body to continue look the same when a div inside overflows to the right?
html {
background-color: #e2e2e2;
margin: 0;
padding: 0;
white-space:nowrap;
}
body {
background-color: #fff;
border-top: solid 10px #000;
color: #333;
font-size: .85em;
font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
margin: 0;
padding: 0;
}
#body {
min-width:1015px;
background-color: #efeeef;
padding-bottom: 35px;
position: relative;
display: inline-block;
vertical-align: top;
}
我在上面的一頁中有css。 #body用於使用ajax通過部分視圖填充的div。
問題是,當#body中的內容溢出到右邊時,body不會封裝#body的內容,它會在加載時保持窗口的大小。 因此,當水平滾動時,滾動時變為可見的區域中的身體部分的背景看起來不同。
當#body owerflows向右移動時,我怎樣才能讓身體繼續看起來一樣?
更新:
Hashem Qolami確實解決了我的部分問題,當放大#body中的內容時,身體仍然包含#body,它看起來應該如此。 但在我的解決方案中加載頁面時,#body中的內容溢出正文並未將內容封裝在#body中。
知道在jsfiddler中運行時可能會有什么不同嗎?
更新2:新的例子
一種選擇是將<body>
顯示類型更改為inline-block
,以使其內容水平增長。
你也可以使用min-width: 100%;
確保<body>
始終填充整個頁面,即使其內容不是那么寬:
html {
white-space:nowrap;
width: 100%;
}
body {
display: inline-block;
min-width: 100%;
}
注意:由於min-width
的百分比值是指包含塊的寬度,因此您還必須指定<html>
元素的顯式寬度(就像我所做的那樣)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.