gpt4 book ai didi

css - 显示表行如何表现得像 colspan=3

转载 作者:技术小花猫 更新时间:2023-10-29 11:32:34 25 4
gpt4 key购买 nike

我需要两行,第一行有 3 列,第二行我需要像 td colspan=3 那样跨越所有宽度

或者显示:table-cell;表现得像 colspan=3

我正在使用 display: table-row;宽度:100%;

如何做到?

这是我的 CSS:

<style>
.boxer {
display: table;
border-collapse: collapse;
}
.boxer .box-row {
display: table-row;
}
.boxer .box-row-search {
display: table-row;
width: 100%;
}
.boxer .box {
display: table-cell;
text-align: left;
vertical-align: top;
border: 1px solid black;
}
</style>

最佳答案

使用 display: table; it cannot be done (遗憾的是,CSS 中没有 colspan: 3;rowspan 属性,因此样式表无法模仿真正的 <table> 元素)

但是嘿,flex来救援!

.row{
display: flex;
flex-flow: wrap;
}
.cell{
width: 25%;
background:#eee;
}
.colspan2{
flex: 2;
}
<div class="row">
<div class="cell">Cell1</div>
<div class="cell">Cell2</div>
<div class="cell">Cell3</div>
<div class="cell">Cell4</div>
<div class="cell">Cell5</div>
<div class="cell colspan2">Cell6 Colspan2</div>
<div class="cell">Cell7</div>
</div>

关于css - 显示表行如何表现得像 colspan=3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36415226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com