如何使div(宽度:自动)调整到嵌套div(浮动左侧和固定宽度)

时间:2016-10-27 17:42:08

标签: html css css-float css-position positioning

我的屏幕上有一个带有width:auto面板,里面有一个对象列表。此列表的元素包含float:leftwidth:380px。 我想将此面板集中在主要div display:flex; justify-content: center;)内的屏幕中。当项目数量适合一行时,它会正确集中,但当需要另一行时,面板使用100%,从行中的最后一项到面板边框的空间很大。图像1和2现在已经完成了。图像3是我想要的。

绿色:主要div , 灰色:面板, blue: list item

图片1:

enter image description here

IMAGE2:

enter image description here

图像3:

enter image description here

为什么在需要第二行时div不适合?

1 个答案:

答案 0 :(得分:0)

由于我没有答案,我解决了为面板设置max-width属性的问题,计算了可能列表项数量的大小。

相关问题