调整大小窗口时如何使两个div相等?

时间:2017-12-03 10:26:26

标签: jquery html css

我有两个div彼此相邻; (浮动:右) 每个div都有段落; 但每个段落有不同的长度; 这使得一个div 更长而另一个更短;当你调整大小窗口时! 当你调整窗口大小时,如何使div相等? 或者当屏幕较小时,如何让它们在彼此之下对齐?当它很大时它们应该是平等的!

谢谢。

1 个答案:

答案 0 :(得分:0)

只需使用flex:



.container {
  display: flex;
}

.container>div {
  flex: 1;
  border: 1px solid;
}

@media all and (max-width:480px) {
  .container {
    flex-direction: column
  }
}

<div class="container">
  <div>Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem</div>
  <div>Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem m ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem Lorem
    ipsuem Lorem ipsuem Lorem ipsuem Lorem ipsuem</div>
</div>
&#13;
&#13;
&#13;