html – 在单独的容器中创建两个div始终对齐

html – 在单独的容器中创建两个div始终对齐,第1张

概述我有两个DIV,它们是在行包装的柔性盒子里. 所以我有两个按钮,我想要始终对齐. .main-container { display: flex; flex-flow: row wrap; justify-content: center;}.container { flex: 1; flex-flow: column wrap; justify-content: 我有两个div,它们是在行包装的柔性盒子里.
所以我有两个按钮,我想要始终对齐.

.main-container {  display: flex;  flex-flow: row wrap;  justify-content: center;}.container {  flex: 1;    flex-flow: column wrap;  justify-content: center;  border: 1px solID gray;  border-radius: 5px;  margin: 5px;  padding: 5px;  min-wIDth: 300px;}.container> * {  flex: 1;}button {  wIDth: 100%;}
<div >  <div >    <h2>        Container 1    </h2>    <div >      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>    </div>    <button>      Click me    </button>  </div>  <div >    <h2>        Container 2    </h2>    <div >      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>      <div>test and this is a long text to wrap around. So let it be</div>      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>    </div>    <button>      Click me    </button>    <div >      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>      <div>test</div>    </div>  </div></div>

在移动分辨率中它应该看起来像

在较小的分辨率,它应该看起来像

在桌面上

Jsfiddle:https://jsfiddle.net/d69jcpnz/

解决方法 试试那个兄弟

.main-container {  display: flex;  flex-flow: row nowrap; /*modification here*/  justify-content: center;}.container {  flex: 1;    flex-flow: column wrap;  justify-content: center;  border: 1px solID gray;  border-radius: 5px;  margin: 5px;  padding: 5px;  min-wIDth: 300px;}.container> * {  flex: 1;}button {  wIDth: 100%;}/*add here*/@media screen and (max-wIDth: 660px) {  .main-container {    flex-flow: row wrap;  }}
总结

以上是内存溢出为你收集整理的html – 在单独的容器创建两个div始终对齐全部内容,希望文章能够帮你解决html – 在单独的容器中创建两个div始终对齐所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1053151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存