我想要成组的表格数据。
想要所有宽度相等的单元格。请参考下面的代码。
.details {
display: table;
width: 100%;
}
.row {
display: table-row;
}
.cell1, .cell2, .cell3 {
width: 100%;
display: table-cell;
border: 1px solid gray;
}
.groups {
border: 1px solid red;
}
.group-name {
font-weight: bold;
}
<div class="details">
<div class="groups">
<div class="group-name">
one
</div>
<div class="list">
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2
</div>
<div class="cell3">
cell3
</div>
</div>
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2
</div>
<div class="cell3">
cell3
</div>
</div>
</div>
</div>
<div class="groups">
<div class="group-name">
two
</div>
<div class="list">
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="cell3">
cell3
</div>
</div>
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="cell3">
cell3 some big Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
</div>
</div>
</div>
最佳答案
添加flex大小相等。
.details {
display: table;
width: 100%;
}
.row {
display: table-row;
display:flex;
}
.cell1{
width: 30%;
display: table-cell;
border: 1px solid gray;
flex: 1;
padding: 1em;
}
.cell2 {
width: 30%;
display: table-cell;
border: 1px solid gray;
flex: 1;
padding: 1em;
}
.cell3 {
width: 30%;
display: table-cell;
border: 1px solid gray;
flex: 1;
padding: 1em;
}
.groups {
border: 1px solid red;
}
.group-name {
font-weight: bold;
}
<div class="details">
<div class="groups">
<div class="group-name">
one
</div>
<div class="list">
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2
</div>
<div class="cell3">
cell3
</div>
</div>
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2
</div>
<div class="cell3">
cell3
</div>
</div>
</div>
</div>
<div class="groups">
<div class="group-name">
two
</div>
<div class="list">
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="cell3">
cell3
</div>
</div>
<div class="row">
<div class="cell1">
cell1
</div>
<div class="cell2">
cell2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="cell3">
cell3 some big Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
</div>
</div>
</div>
关于html - 使用具有分组div的div获取表结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39202299/