流体网格布局

我正在创建一个表格。在表单中,我有20多个html控件,即文本框,复选框,文本区域。我想以表格格式排列所有html元素。但是,当屏幕尺寸减小时,列数应减少。 例。最初将有4列。当屏幕尺寸减小时,没有列变为3。在进一步屏幕尺寸减小时,没有列变为2,然后变为1。

如何实现?

wmwm9433 回答:流体网格布局

使用Flexbox Layout设计灵活的响应式布局结构:

Subject_Section_Teacher=teachers.all()
* {box-sizing: border-box;}

/* Style Row */
.row {
  display: -webkit-flex;
  -webkit-flex-wrap: wrap;
  display: flex;
  flex-wrap: wrap;
}

/* Make the columns stack on top of each other */
.row > .column {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
}

/* Responsive layout - makes a two column-layout (50%/50% split) */
@media screen and (min-width: 600px) {
  .row > .column {    
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* Responsive layout - makes a four column-layout (25%/25% split) */
@media screen and (min-width: 991px) {
  .row > .column {    
    flex: 0 0 25%;
    max-width: 25%;
  }
}

参考: Create a Mixed Column Layout

本文链接:https://www.f2er.com/3162545.html

大家都在问