当前位置:  开发笔记 > 编程语言 > 正文

如何在表格行中重定位表格单元格?

如何解决《如何在表格行中重定位表格单元格?》经验,为你挑选了1个好方法。

我有一个tr和3 td.我需要将第一和第三td宽度分别设为50%,第二个宽度为100%,并且在这两行之下.我知道这是一项奇怪的任务,但我需要用css或js做到这一点.在此输入图像描述



1> Brett DeWood..:

另一种更优雅的方法,使用flex-boxorder属性.

table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapsed;
}

tr {
  display: flex;
  flex-wrap: wrap;
}

td {
  text-align: center;
  line-height: 30px;
  flex: 1;
  width: 50%;
  
  border: 2px solid white;
  background-color: gray;
}

td:nth-child(2) {
  order: 3;
  min-width: calc(100% - 6px);
}
A B C is a really, really, really long content box, showing how the height of a cell doesn't make a difference.
推荐阅读
家具销售_903
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有