这是我的 html 代码:
<div class="container-fluid d-flex h-100">
<div class="white h-100" style="background-color: white;">
fixed 100px
</div>
<div class="col-3 blue h-100" style="background-color: blue;">
3
</div>
<div class="col-6 red h-100" style="background-color: red;">
6
</div>
<div class="col-3 blue h-100" style="background-color: blue;">
3
</div>
</div>
你能帮我修复我的代码吗?我需要固定宽度的左侧列,它将有 100px。此列尚未调整大小。我需要的其余空间应该可以按 1 : 2 : 1 的比例动态调整。感谢您的帮助。
原文由 Denis Stephanov 发布,翻译遵循 CC BY-SA 4.0 许可协议
@Denis Stephanov,您可以使用以下 css 规则创建一个不会收缩或增长且宽度固定的弹性项目:
这是
flex-grow
、flex-shrink
和flex-basis
的缩写。您可以在这篇 CSS-Tricks 文章 中阅读有关这些属性的更多信息。将该类添加到固定宽度列中:
然后保持你的列比率相同:
您将获得您请求的结果,您可以在此 codeply 项目 中查看。