参考Vertical and horizontal align of divs
和这段新代码http://jsfiddle.net/8B29k/2/
为什么“底部的盒子”没有覆盖整个宽度?
我不想让我们使用html colspan(在这种情况下不能这样,因为盒子会动态生成,我可能自己也不会知道有多少盒子是上下两个方向)
除了它之外或之上/之下,每个盒子都独立于盒子。那就是表格的情况。如果在每个TR中存在3个TR和3个TD,则不能使中间TR仅具有一个TD并且将其宽度扩展为等于其他TR(所有TD组合)。不能在没有colspan的情况下这样做。但在这种情况下。我自己不会知道周围的TD。那么它的解决方案是什么?
这是我想要创建的布局:
.board{
display:block;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: red solid thin;
/**min-height:510px;**/
}
.board-title{
background-color:black;
color:white;
font-size:50px;
}
.board-body{
}
.box{
vertical-align:top;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: blue solid thin;
/**min-height:500px;**/
min-width:160px;
height:100%;
}
.box-title{
width:100%;
background-color:grey;
font-size:50px;
}
.box-body{
display:table-row;
}
.box-parent{
}
.box-vertical{
display:table-cell;
vertical-align:top:
vertical-align:top;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: blue solid thin;
/**min-height:500px;**/
min-width:160px;
height:100%;
}
.box-horizontal{
display:table-row;
vertical-align:top;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: blue solid thin;
/**min-height:500px;**/
min-width:160px;
height:100%;
}
.task{
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
display:block;
float: left;
border: green solid thin;
width:150px;
height:100px;
}
HTML看起来像:
<div class="board">
<div class="board-title">board title-
</div>
<div class="board-body">
<div class="box-vertical">
<div class="box-title">box1 title-
</div>
<div class="box-body">
<div class="box-vertical">
<div class="box-title">inner box title
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">box at side title-
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-horizontal">
<div class="box-title">box at bottom - title
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
http://jsfiddle.net/7brCZ/7/ http://jsfiddle.net/7brCZ/7/embedded/result/
.board{
display:block;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: red solid thin;
/**min-height:510px;**/
}
.board-title{
background-color:black;
color:white;
font-size:50px;
}
.board-body{
}
.box{
vertical-align:top;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: blue solid thin;
/**min-height:500px;**/
min-width:160px;
height:100%;
}
.box-title{
width:100%;
background-color:grey;
font-size:50px;
}
.box-body{
display:table;
}
.box-parent{
}
.box-vertical{
display:table-cell;
vertical-align:top:
vertical-align:top;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: blue solid thin;
/**min-height:500px;**/
min-width:160px;
height:100%;
}
.box-horizontal{
vertical-align:top;
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
border: blue solid thin;
/**min-height:500px;**/
min-width:160px;
height:100%;
}
.task{
margin-right:5px;
margin-left:5px;
margin-top:10px;
margin-bottom:10px;
display:block;
float: left;
border: green solid thin;
width:150px;
height:100px;
}
<div class="board">
<div class="board-title">board
</div>
<div class="board-body">
<div class="box-vertical">
<div class="box-title">box at virtical
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">box at virtical
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">box virtical
</div>
<div class="box-body">
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">box at side
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-horizontal">
<div class="box-title">box at horizontal
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-horizontal">
<div class="box-title">box at horizontal
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-horizontal">
<div class="box-title">box at horizontal
</div>
<div class="box-body">
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
<div class="box-vertical">
<div class="box-title">inner virtical box
</div>
<div class="box-body">
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
<div class="task">
</div>
</div>
</div>
</div>
</div>
</div>
</div>