CSS3中webkit-box布局頁面執行個體,css3webkit-box
之前布局都是用float布局或者是display:inline-block;+width:**%;來計算,所以都不是真正意義上的流布局;接下來的執行個體能完整的教給大家如何建立CSS3當中的流布局(以chrome為例)
<!DOCTYPE html>
<html>
<meta charset=”utf-8″ />
<style>
.wrap {
display: -webkit-box;
-webkit-box-orient: horizontal;
}
.child {
min-height: 200px;
border: 2px solid #666;
-webkit-box-flex: 1;
margin: 10px;
font-size: 100px;
font-weight: bold;
font-family: Georgia;
-webkit-box-align: center;
}
</style>
<div class="wrap">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
</div>
</html>
<!DOCTYPE html><html>
<meta charset=”utf-8″ />
<style>
.wrap {
display: -webkit-box;
-webkit-box-orient: horizontal;
}
.child {
min-height: 200px;
border: 2px solid #666;
margin: 10px;
font-size: 40px;
font-weight: bold;
font-family: Georgia;
-webkit-box-align: center;
}
.w200 {width: 200px}
.flex1 {-webkit-box-flex: 1}
.flex2 {-webkit-box-flex: 2}
</style>
<div class="wrap">
<div class="w200 child">200px</div>
<div class="flex1 child">比例1</div>
<div class="flex2 child">比例2</div>
</div>
</html>
<!DOCTYPE html><html> <meta charset=”utf-8″ />
<style>
header, footer,section {
border: 10px solid #333;
font-family: Georgia;
font-size: 40px;
text-align: center;
margin: 10px;
-webkit-box-flex:1;
}
#doc {
height: 100%;
display: -webkit-box;
-webkit-box-orient: vertical;
margin: 0 auto;
}
header,footer {
min-height: 100px;
-webkit-box-flex: 1;
}
#content {
min-height: 400px;
display: -webkit-box;
-webkit-box-orient: horizontal;
}
.w200 {width: 200px}
.flex1 {-webkit-box-flex: 1}
.flex2 {-webkit-box-flex: 2}
.flex3 {-webkit-box-flex: 3}
</style>
<div id="doc">
<header>Header</header>
<div id="content">
<section>定寬200</section>
<section>比例3</section>
<section>比例1</section>
</div>
<footer>Footer</footer>
</div>
</html>