gpt4 book ai didi

CSS3 : how to create 3 flexible columns?

转载 作者:太空宇宙 更新时间:2023-11-03 17:31:31 26 4
gpt4 key购买 nike

我的目标是创建一个 3 列布局:

  • 第一列可以取任意宽度:它会通过 JS 改变
  • 第二列尽可能多地占用空间
  • 第三列固定宽度

#red {
background-color:red;
display:inline-block;
width:100px; /* this can change */
}
#green {
background-color:green;
display:inline;
width:100%; /* this should take ALL the place available */

}
#blue {
background-color:blue;
display:inline-block;
width:200px; /* this is fixed width */
}
<div id="container">
<div id="red">red</div>
<div id="green">green</div>
<div id="blue">blue</div>
</div>

这可能没有任何 JS 吗?

最佳答案

我会使用显示表。兼容 IE8+。

#container {
display: table;
width: 100%;
height: 300px;
}

#red {
display: table-cell;
width: 100px;
background: red;
}

#blue {
display: table-cell;
background: blue;
}

#green {
display: table-cell;
width: 100px;
background: green;
}
<div id="container">
<div id="red"></div>
<div id="blue"></div>
<div id="green"></div>
</div>

关于CSS3 : how to create 3 flexible columns?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30469551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com