gpt4 book ai didi

html - 如何在父 DIV 中对齐水平 DIV?

转载 作者:行者123 更新时间:2023-11-28 18:17:59 26 4
gpt4 key购买 nike

我想在父 div #main 中对齐水平 DIVS 并隐藏水平滚动我试着这样做:http://jsfiddle.net/Ty9kg/30/

<div id="main">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>

#main {
border:1px solid black;
width:250px;
height:150px;
overflow-y:hidden;
overflow-x:scroll;
}

#main div {
width:165px;
height:120px;
display:inline-block;
float:left;
background:#ccc;
border:1px solid #ccc
}

最佳答案

你想要the following

#main {
border:1px solid black;
width:250px;
height:150px;
overflow-y:hidden;
overflow-x:scroll;
white-space: nowrap;
}

#main div {
width:165px;
height:120px;
display:inline-block;
background:#ccc;
border:1px solid #ccc;
white-space: normal;
}

如果是这样,float 在您的代码中是多余的。

关于html - 如何在父 DIV 中对齐水平 DIV?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17645056/

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