边栏高度伸展与内容高度CSS [英] Sidebar height stretch with the content height CSS

查看:177
本文介绍了边栏高度伸展与内容高度CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个DIV:

<div id="sidebar"></div>
<div id="content"></div>

我如何使侧边栏的div与内容的高度相同。

How would i make the sidebar div stretch the same height as the content.

感谢任何帮助。

更新:

与其他元素的代码:

http://tinkerbin.com/tkp2FZLZ

它在中间有一个内容DIV,有4个div,这使得边框是不同的颜色。

it has a content DIV in the Middle and 4 divs that makes border which is a different color.

推荐答案

您可以通过 display:table-cell;

HTML

<div id="sidebar">sidebar</div>

<div id="content">content</div>

CSS

#sidebar {
display:table-cell;
width:100px;
background:red;

}
#content {
display:table-cell;
width:100px;
background:yellow;
height:200px;
}

我认为你看起来像这样 -
http://tinkerbin.com/yqyX3mXg

i think you are looking like this ;- http://tinkerbin.com/yqyX3mXg

这篇关于边栏高度伸展与内容高度CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆