可能重复:为什么 css min-width 属性不强制 div 具有指定的最小宽度?
我的网站: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
(根据 这个问题)——与min-width
一起使用时,盒子缩小得更小。
-
#CWrapper
上的 float:left;
(根据 这个问题)
- 将
min-width
属性应用于两个静态像素(基于1024x768 分辨率)和可变长度/百分比
提前致谢!
Possible duplicate: why does the css min-width attribute not force a div to hae the specified minimum width?
My Website: http://tg.unifiedtech.org/
I'm working on a layout that's quite complex (for me at least) to style. However, I styled the main content area for this website with large-content, not Wordpress' default 'Hello World' post which is quite tiny.
The style looks alright when you see content that is quite long, but when the content is only one sentence, the #CWrapper
squishes down to something undesirable. I don't get why. :/
Affected page/post: http://tg.unifiedtech.org/2011/12/17/hello-world/
Question: Why doesn't the browser (Chrome/FF atm) use the margin I define to define the width of #CWrapper
?
Things I've tried:
position:absolute;
on #CWrapper
(as per this question) -- When used with min-width
, the box shrunk even smaller.
float:left;
on #CWrapper
(as per this question)
- Applied
min-width
property with both static pixels (based on 1024x768 resolution) and variable-length/percentages
Thanks in advance!
发布评论
评论(1)
只需从
#Wrapper
中删除position:absolute
- 如果您向元素添加绝对定位,它将失去其width:auto
(= 默认值div,表示其父级的 100%)。由于#Wrapper
失去了宽度,子元素无法继承它。Just remove
position:absolute
from#Wrapper
- if you add absolute positioning to an element, it looses itswidth:auto
(= default value for a div, meaning 100% of its parent). Since#Wrapper
has lost its width, child elements can't inherit it.