gpt4 book ai didi

CSS宽度自动在一行中最大

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

我连续有 2 个 div(带有内联 block )。其中一个具有固定宽度,另一个应该自动填充左侧空间。我该怎么做?

最佳答案

我最喜欢的解决方案是在容器 block 上使用填充,在固定对象上使用绝对位置:

.wrapper {
padding-left: 100px;
position: relative;
}

.stay {
width: 100px;
position: absolute;
left: 0;
top: 0;

/* for demo */
height: 50px;
background-color: pink;
}

.fit {
width: 100%;

/* for demo */
height: 50px;
background-color: red;
}

HTML:

<div class="wrapper">
<div class="stay"></div>
<div class="fit"></div>
</div>

关于CSS宽度自动在一行中最大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26185077/

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