Possible duplicate: why does the css min-width attribute not force a div to hae the specified minimum width?
我的网站:http://tg.unifiedtech.org/
我正在设计一个样式非常复杂(至少对我而言)的布局。然而,我为这个网站的主要内容区域设置了大内容样式,而不是 Wordpress 默认的“Hello World”帖子,它非常小。
当您看到很长的内容时,样式看起来还不错,但是当内容只有一个句子时,#CWrapper
就会压缩成一些不受欢迎的东西。我不明白为什么。 :/
受影响的页面/帖子:http://tg.unifiedtech.org/2011/12/17/hello-world/
问题:为什么浏览器(Chrome/FF atm)不使用我定义的边距来定义#CWrapper
的宽度?
我尝试过的事情:
position:absolute;
on#CWrapper
(根据 this question )——当与min-width
一起使用时,框会缩小甚至更小。float:left;
在#CWrapper
上(根据 this question )- 应用了静态像素(基于 1024x768 分辨率)和可变长度/百分比的
min-width
属性
提前致谢!
最佳答案
只需从 #Wrapper
中删除 position:absolute
- 如果您向元素添加绝对定位,它会失去其 width:auto
(= div 的默认值,表示其父级的 100%)。由于 #Wrapper
失去了宽度,子元素无法继承它。
关于html - block 元素的边际大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8563841/