开发者

CSS: Parent/Child height issue

I'm stru开发者_运维问答ggling with a sidebar height.

My container is now showing the correct height (that of the content inside), but my sidebar that should be using 100% of that height is still not appearing.

I've implemented one of the suggestions below (http://www.quirksmode.org/css/clearing.html) but the sidebar's still not appearing.

I'm sure this is a simple one for you pros, any tips appreciated!

Thanks,

Tom

Here's my code: http://jsfiddle.net/tomperkins/wy52B/


Check out this way of clearing floats, it's a lot cleaner and easier to use.


Don't use clearfix

It's not necessary in most situations, and it's definitely not semantic.

The simple solution for most cases: float the parent.

HTML:

<div class="parent">
  <div class="child">
  </div>
  <div class="child">
  </div>
</div>

CSS:

.parent
{
  float: left;
  width: 100%; /*or whatever you want it to be*/
}

.child
{
  float: left;
  width: 50%;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜