既然對這個問題有一些興趣,我會給你我目前找到的解決方案。它是在Chrome中測試的(目前沒有其他瀏覽器使用這個示例,但在FF中工作時又有更大的工作量,當我「簡單地工作」時,這種工作方式不起作用)。
背後的想法是,以某種方式使嵌套在柔性盒內的元素延伸到彈性框元素的全尺寸。爲此,在內部添加絕對位置元素,其距離左側,右側,頂部和底部的距離爲0。
然而,即使在鍍鉻,有一個錯誤,downsizeing和調整大小的元件,使得所述滾動條在前看不見時。
下面是HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>flexbox example - 2 column layout</title>
<meta name="author" content="Gwilym Johnston">
<style type="text/css">
html, body{
height: 100%;
margin: 0px;
}
#box-orient-example {
-moz-box-orient: horizontal;
-webkit-box-orient: horizontal;
-ms-box-orient: horizontal;
box-orient: horizontal;
display: -moz-box;
display: -webkit-box;
display: -ms-box;
display: box;
height: 100%;
overflow: auto;
}
#box1 {
-moz-box-flex: 1;
-webkit-box-flex: 1;
-ms-box-flex: 1;
background: none repeat scroll 0 0 lightblue;
text-align: center;
overflow: auto;
position: relative;
}
#box2 {
-moz-box-flex: 1;
-webkit-box-flex: 1;
-ms-box-flex: 1;
background: none repeat scroll 0 0 #DDDDDD;
text-align: center;
overflow: auto;
position: relative;
}
.abs {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.rel{
position: relative;
}
</style>
</head>
<body>
<div id="box-orient-example" class="example">
<div id="box1">
<div class="abs">
<div class="rel">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
</div>
</div>
<div id="box2">
<div class="abs">
<div class="rel">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</div>
</div>
</div>
</body>
</html>
「height:100%」是否發出webkit錯誤?或者是W3C建議中定義的那個? – Xenos