gpt4 book ai didi

html - CSS 溢出和空白不起作用

转载 作者:行者123 更新时间:2023-11-28 03:58:24 25 4
gpt4 key购买 nike

现状

使用以下代码,我显示了几个 float 到左侧的 div。

* {
margin: 0;
padding: 0;
border: none;
box-sizing: border-box;
}

.container {
width: 100%;
height: 100%;
}

.header {
height: 80px;
position: fixed;
width: 100%;
background: green;
}

.inner-container {
position: absolute;
top: 80px;
left: 0px;
right: 0px;
bottom: 0px;
overflow: auto;
white-space: nowrap;
}

.column {
height: 500px;
width: 150px;
background: red;
float: left;
margin: 5px;
}
<div class="container">
<div class="header">
</div>

<div class="inner-container">
<div class="column">
</div>
<div class="column">
</div>
<div class="column">
</div>
</div>
</div>

当前结果:

enter image description here

问题

我想要的是红色框不包裹在其容器内。如果空间不够,我想要一个垂直和水平滚动条。对于垂直滚动条,它有效。我错过了什么?

JSFiddle:https://jsfiddle.net/brainchest/j6zh400v/

最佳答案

我发现的一个修复方法是将 .columnfloat: left 更改为 display: inline-block。这会将每一列视为一个“单词”(就像文本中的一个单词),因此 white-space: no-wrap; 适用。否则,float: left 会更改元素的定位方式。

编辑 fiddle :https://jsfiddle.net/9bo4f5pv/

关于html - CSS 溢出和空白不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43336246/

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