我有一个左右的flexbox:
.wrapper { display: flex; flex-direction: row; align-items: stretch; width: 100%; height: 70vh; min-height: 325px; max-height:570px; }
<div class="wrapper"> <div class="left">Left</div> <div class="right">Right</div> </div>
问题是,正确的孩子没有表现出反应.具体来说,我希望它填充包装器的高度.怎么做到这一点?
谢谢,
黛比
解决方法
>行 – flexbox容器的子项自动填充容器的垂直空间.
>指定flex:1;对于孩子,如果你想让它填补剩余的水平空间:
>指定flex:1;对于孩子,如果你想让它填补剩余的水平空间:
.wrapper { display: flex; flex-direction: row; align-items: stretch; width: 100%; height: 5em; background: #ccc; } .wrapper > .left { background: #fcc; } .wrapper > .right { background: #ccf; flex: 1; }
<div class="wrapper"> <div class="left">Left</div> <div class="right">Right</div> </div>
>指定flex:1;对于两个孩子,如果你想让他们填充相等数量的水平空间:
.wrapper { display: flex; flex-direction: row; align-items: stretch; width: 100%; height: 5em; background: #ccc; } .wrapper > div { flex: 1; } .wrapper > .left { background: #fcc; } .wrapper > .right { background: #ccf; }
<div class="wrapper"> <div class="left">Left</div> <div class="right">Right</div> </div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。