html - 如何在延续上一栏内容的页面中创建多个栏。 - HTML,CSS

标签 html css

首先,对于任何语法错误,我深表歉意,我不是英语专家。

所以,我需要的是将我的页面分成支持一个表的三个列,当这个表达到一个列时,例如,高度:1000px,它将转到另一个专栏。

我试着在 Paint 中做了一个简单的例子:

enter image description here

我尝试的所有操作都只是将页面分成三列,但它们并没有像我想要的那样相互交互。有什么办法吗?

P.S:这个表是从我的数据库中创建的,所以它不是一个固定的表。

最佳答案

我觉得在某种程度上,当它成为标准时,这将是 CSS Grid Layout 的一个不错的用例。 ,或者至少它可能更语义化。但是现在你绝对可以将 flexbox 样式应用于 <table> :

table {
  /* forces the table to be full width 
     even without enough content */
  display: block;
}

tbody {
  border: 1px solid black;

  /* display flex will reflow child elements 
     once they hit a limit in their parent */
  display: flex;

  /* flex-flow sets the direction to flow child elements, 
     and if they should wrap when hitting 
     the end of their parent */
  flex-flow: column wrap;

  max-height: 80px;
  width: 100%;
}

tr {
  border: 1px solid #bad;

  /* the 33% (the flex basis) is how i'm 
     getting 3 columns, adjusting this will adjust 
     your number of columns, it's not the most general solution, 
     but it'll work for you case */
  flex: 0 0 33%;
}

td {
  border: 1px solid #ace;
}
<table>
  <tbody>
    <tr>
      <td>row data</td>
    </tr>

    <tr>
      <td>row data</td>
    </tr>

    <tr>
      <td>row data</td>
    </tr>

    <tr>
      <td>row data</td>
    </tr>

    <tr>
      <td>row data</td>
    </tr>
  </tbody>
</table>

关于html - 如何在延续上一栏内容的页面中创建多个栏。 - HTML,CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47041366/

相关文章:

css - SVG动画解释

页面上最后一次出现的类的 CSS 选择器

html - 灵活的布局。如何在没有 CSS 的情况下显示条件内容?

javascript - 在 JS 中获取文档上的当前页面访问者

html - html5 文档的正确 mime 类型是什么?

html - Tumblr 主题 : ul, il 间距问题?

css - 为什么这个按钮在另一个按钮的右边,为什么不在左边?

javascript - 如何在 url 参数中包含 url 参数(它将嵌套参数视为原始请求的参数)

jquery 在调整窗口大小时计算元素大小

javascript - 在 Chrome 中设置动画时隐藏的 Angular 落变得可见