我創建了一個網格佈局,像這樣(JSFIDDLE):CSS - 網格/砌體佈局
HTML:
<div class="grid-box">
<div class="item-9">
<div class="box-1"></div>
<div class="box-2"></div>
<div class="box-3"></div>
<div class="box-4"></div>
<div class="box-5"></div>
<div class="box-6"></div>
<div class="box-7"></div>
<div class="box-8"></div>
<div class="box-9"></div>
</div>
</div>
CSS:
.grid-box > .item-9 > .box-1 {
background: none repeat scroll 0 0 #990066;
display: inline-block;
float: left;
height: 200px;
width: 49%;
}
.grid-box > .item-9 > .box-2 {
background: none repeat scroll 0 0 #3333FF;
display: inline-block;
float: right;
height: 400px;
width: 26%;
}
.grid-box > .item-9 > .box-3 {
background: none repeat scroll 0 0 #993366;
display: inline-block;
float: right;
height: 100px;
width: 25%;
}
.grid-box > .item-9 > .box-4 {
background: none repeat scroll 0 0 #FF66FF;
display: inline-block;
float: right;
height: 100px;
width: 25%;
}
.grid-box > .item-9 > .box-5 {
background: none repeat scroll 0 0 #CC66CC;
display: inline-block;
float: left;
height: 140px;
width: 24.5%;
}
.grid-box > .item-9 > .box-6 {
background: none repeat scroll 0 0 #9966CC;
display: inline-block;
float: left;
height: 140px;
width: 24.5%;
}
.grid-box > .item-9 > .box-7 {
background: none repeat scroll 0 0 #CC6699;
display: inline-block;
float: right;
height: 100px;
width: 25%;
}
.grid-box > .item-9 > .box-8 {
background: none repeat scroll 0 0 #9966CC;
display: inline-block;
float: right;
height: 100px;
width: 25%;
}
.grid-box > .item-9 > .box-9 {
background: none repeat scroll 0 0 #990066;
display: inline-block;
float: left;
height: 60px;
width: 49%;
}
然後,我遇到了一個輕微問題,我需要box-2左對齊到block-1,所以基本上我需要用4個彩色塊切換大塊藍色塊的位置。我已經放置'>'和'<'箭頭來說明我的意思。
另外我不能編輯HTML,因爲它是由PHP生成的..我只能編輯CSS。此外,我不能編輯大小,如寬度和高度。
任何幫助非常感謝。
我的意思是......如果尺寸和位置是固定的,你可以總是絕對位置所有的框 – Jason
那些框的大小是靜態的? (我看到你有固定的像素) – avrahamcool
它們在高度上是靜態的,但寬度在960容器中爲% –