首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS表行和单元格宽度

CSS表行和单元格宽度
EN

Stack Overflow用户
提问于 2018-05-28 23:29:15
回答 1查看 33关注 0票数 1

这里我有一个非常棘手的问题。)如何使第三个单元格的宽度为100%,并使底部行从第一行开始独立?

代码语言:javascript
复制
/* Table */

* {
  box-sizing: border-box;
}

.table {
  display: table;
  width: 300px;
  margin-bottom: 1rem;
  border: 2px solid rgba(255, 0, 0, .40);
}

/* Grid */

.row {
  display: table-row;
}

.cell {
  display: table-cell;
}

/* Grid Width */

.cell-1 {
  width: 50%;
}

.cell-2 {
  width: 100%;
}

/* Decoration */

body {
  font-family: monospace;
  font-size: 15px;
}

.cell {
  line-height: 3;
  text-align: center;
  background-color: rgba(255, 0, 0, .3);
  border: 1px solid white;
}
代码语言:javascript
复制
<div class="table">
  <div class="row">
      <div class="cell cell-1">1</div>
      <div class="cell cell-1">2</div>
  </div>
  <div class="row">
      <div class="cell cell-3">3</div>
  </div>
</div>

EN

回答 1

Stack Overflow用户

发布于 2018-05-28 23:52:39

我用Table标签重写了你的程序。程序写在下面。

代码语言:javascript
复制
* {
  box-sizing: border-box;
}
table {
  display: table;
  width: 300px;
  margin-bottom: 1rem;
  border: 2px solid rgba(255, 0, 0, .40);
}

/* Grid */

tr {
  display: table-row;
}

td {
  display: table-cell;
}

/* Decoration */

body {
  font-family: monospace;
  font-size: 15px;
}

td {
  line-height: 3;
  text-align: center;
  background-color: rgba(255, 0, 0, .3);
  border: 1px solid white;
}
代码语言:javascript
复制
<table>
  <tr>
    <td>1</td>
    <td>2</td>
  </tr>
  <tr>
    <td colspan="2">3</td>
  </tr>
</table>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50569562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档