gpt4 book ai didi

html - 如何在 overflow hidden 时防止 div 换行?

转载 作者:行者123 更新时间:2023-11-28 08:36:20 25 4
gpt4 key购买 nike

目前我有一行包含多个 div。我试图防止包含的 div 换行。我也不想要滚动条。我试过 overflow hidden 并在行上设置宽度。

编辑:约束规定这必须在没有表、javascript 或外部库的情况下完成。

有没有办法在不借助表格的情况下使用 css 做到这一点?

JSFiddle:http://jsfiddle.net/ozsumdfb/

HTML:

<div class="row">
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
</div>

CSS:

.square {
width:100px;
height:100px;
float:left;
margin-left:3px;
background-color: #6C6;
}
.row {
width:500px;
overflow:hidden;
}

最佳答案

代替 float:left 你可以尝试 display:inline-block 然后添加:

.row {white-space:nowrap; }

这是你要找的吗?

fiddle

关于html - 如何在 overflow hidden 时防止 div 换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28018784/

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