【问题标题】:What's the math for building a Grid system with flexbox (rows and columns)?使用 flexbox(行和列)构建网格系统的数学原理是什么?
【发布时间】:2020-05-03 02:44:12
【问题描述】:

我对使用 flex-box 的自定义网格系统的宽度感到困惑。我不知道我需要在我的专栏中使用的数学。这是一个 12 列的网格。 目前,我不会使用间隙(边距)。我需要列的宽度是百分比。

顺便说一句:我现在不想使用 flex-grow,只是宽度。

如何计算每列的每个宽度?

【问题讨论】:

  • 为什么不直接使用css网格?
  • BTW: I don't want to use flex-grow for now, just widths. 那你为什么要使用 flexbox 呢?
  • 用于跨轴移动孩子

标签: css flexbox


【解决方案1】:

您可以访问 w3schools.org

上的此页面

链接https://www.w3schools.com/css/css_rwd_grid.asp

不使用 flex system。它使用 float system

或在您的 css 上使用此代码(flex 系统):

.row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  /* or using short= flex-flow: row wrap; */
}

[class*="col-"] {
  padding: 15px;
  border: 1px solid red;
}

.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}

如果您还有其他问题,我也可以帮助您。

【讨论】:

    猜你喜欢
    • 2018-10-10
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    • 2019-07-03
    • 1970-01-01
    • 2015-05-24
    • 2020-02-15
    • 1970-01-01
    相关资源
    最近更新 更多