我想創建DIV HEAD作爲表,但是當我添加另一個頭時,它顯示下來,而不是右側。如何創建自動寬度的表格div?
換句話說,我希望表格是六列寬,但只有3列,行開始疊加。
這裏有一個現場演示:
.rTable {
display: block;
width: 100%;
font-size: 10px;
}
.rTableHeading, .rTableBody, .rTableFoot, .rTableRow{
clear: both;
}
.rTableHead, .rTableFoot{
background-color: #DDD;
font-weight: bold;
}
.rTableCell, .rTableHead {
border: 1px solid #999999;
float: left;
height: 17px;
overflow: hidden;
padding: 3px 1.8%;
width: 28%;
}
<div class="rTable">
<div class="rTableRow">
<div class="rTableHead">HEAD 1</div>
<div class="rTableHead">HEAD 2</div>
<div class="rTableHead">HEAD 3</div>
<div class="rTableHead">HEAD 4</div>
<div class="rTableHead">HEAD 5</div>
<div class="rTableHead">HEAD 6</div>
</div>
<div class="rTableRow" style="page-break-before:always;">
<div class="rTableCell">row 1.1</div>
<div class="rTableCell">row 1.2</div>
<div class="rTableCell">row 1.3</div>
<div class="rTableCell">row 1.4</div>
<div class="rTableCell">row 1.5</div>
<div class="rTableCell">row 1.6</div>
</div>
<div class="rTableRow" style="page-break-before:always;">
<div class="rTableCell">row 2.1</div>
<div class="rTableCell">row 2.2</div>
<div class="rTableCell">row 2.3</div>
<div class="rTableCell">row 2.4</div>
<div class="rTableCell">row 2.5</div>
<div class="rTableCell">row 2.6</div>
</div>
<div class="rTableRow" style="page-break-before:always;">
<div class="rTableCell">row 3.1</div>
<div class="rTableCell">row 3.2</div>
<div class="rTableCell">row 3.3</div>
<div class="rTableCell">row 3.4</div>
<div class="rTableCell">row 3.5</div>
<div class="rTableCell">row 3.6</div>
</div>
</div>
如果我添加了超過6個字,並且以HEAD爲例:而不是HEAD1顯示員工姓名 - 妻子名字......這將是一個問題......有沒有其他方式可以以動態的方式進行此操作? –
對於更長的頭部標題,您有兩個選項:1.給表格增加寬度或2.將長標題分成多行... – andreas
感謝它的工作。 –