flexbox项目上的宽度被忽略 [英] Width ignored on flexbox items
问题描述
我将 width:200px;
设置在左侧的< div>
上,但是如果我查看的话使用浏览器检查器工具,实际宽度似乎是随机的或某种程度。
I've set width: 200px;
on the left <div>
but if I view it with the browser inspector tool it appears that the real width is random or something. It keeps changing depending on the window size.
为什么宽度不生效?
>编辑:如果我删除 width:100%
,宽度保持固定。但是我需要这样,以便 #main
div占用剩余的宽度:(有什么方法可以使侧边栏@固定宽度,而其他< div>
填充其余的容器宽度吗? width:auto;
不起作用。. #main
上的
EDIT: If I remove width: 100%
the width stays fixed. But I need that so the #main
div takes the remaining width :( Is there any way to have the sidebar @ fixed width and the other <div>
fill the rest of the container width? width: auto;
on #main
doesn't work..
推荐答案
删除 .container> div $ c上的宽度$ c>并使用
flex:auto;
在 #main
上:小提琴
#main {
flex: auto;
background: lightblue;
-webkit-order: 2;
order: 2;
}
这篇关于flexbox项目上的宽度被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!