【问题标题】:How to change column width based on the number of columns present?如何根据存在的列数更改列宽?
【发布时间】:2019-02-18 12:40:03
【问题描述】:

以下面的 reactstrap 为例:

       <Container fluid>
        <Row>
          <Col md={4}>
            <TodoAdd />
          </Col>
          <Col md={8}>
            <TodoList />
          </Col>
        </Row>
      </Container>

有时,DOM 中不存在第二列。发生这种情况时,我希望第一列的“md”属性为 {12}。

换一种说法,我希望列是流动的,即当兄弟列不存在时占据行的整个宽度。

【问题讨论】:

    标签: twitter-bootstrap reactstrap


    【解决方案1】:

    你可以这样做:

      <Container fluid>
        <Row>
          <Col>
            <TodoAdd />
          </Col>
          <Col md={8}>
            <TodoList />
          </Col>
        </Row>
      </Container>
    

    第一列将占用其他列(通过 md、sm 等)提及其大小的列所留下的任何空间

    【讨论】:

      猜你喜欢
      • 2017-09-05
      • 1970-01-01
      • 2011-02-15
      • 1970-01-01
      • 2011-04-11
      • 2014-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多