Same height column bootstrap 3 row responsive

后端 未结 16 1734
难免孤独
难免孤独 2020-11-30 00:04

Hi I have four divs in a bootstrap row. I want all divs in this row to have the same height and not break responsibility. I don\'t know how to do this without breaking respo

16条回答
  •  無奈伤痛
    2020-11-30 00:21

    For people who are coming here for this solution in React, here it is:

      constructor(props) {
        super(props);
        this.state = {
          maxHeight: undefined,
        };
    
        this.putBootstrapColumnSameHeight = this.putBootstrapColumnSameHeight.bind(this);
      }
    
      componentDidMount() {
        this.putBootstrapColumnSameHeight();
      }
    
      putBootstrapColumnSameHeight() {
        const heights = [];
        document.querySelectorAll('.col').forEach(el => heights.push(el.clientHeight));
        this.setState(
          {
            maxHeight: Math.max.apply(null, heights),
          },
        );
      }
    

    Then to your columns :

    
     // etc..
    
    
    
     // etc..
    
    

    Enjoy ;)

提交回复
热议问题