如何将两个div水平放置在另一个div中 [英] How to position two divs horizontally within another div
问题描述
我没有玩CSS太长时间,目前没有参考。我的问题应该是相当容易,但谷歌不是提出一个足够的答案。所以,添加到集体的知识...
I haven't played with CSS for too long a time and am without references at the moment. My question should be fairly easy but googling isn't bringing up a sufficient answer. So, adding to the collective knowledge...
|#header---------------------------------------------------------------|
| TITLE |
|#sub-title------------------------------------------------------------|
|bread > crumb | username logout |
|#sub-left | #sub-right|
|---------------------------------|------------------------------------|
这就是我想要的布局。标题反正。我想要子标题包含sub-left和sub-right。我使用什么css规则来确保div由另一个div的属性绑定。在这种情况下,如何确保sub-left和sub-right保留在子标题中?
That's what I'm wanting my layout to be. The heading anyways. I wanted sub-title to contain sub-left AND sub-right. What css rules do I use to ensure a div is bound by the attributes of another div. In this case, how do I ensure that sub-left and sub-right stay within sub-title?
推荐答案
这是一个常见的误解,你需要一个 clear:both
div在底部,当你真的不。虽然狡猾的答案是正确的,你不需要非语义,无用的清除div。所有你需要做的是在容器上粘贴 overflow:hidden
:
Its quite a common misconception that you need a clear:both
div at the bottom, when you really don't. While foxy's answer is correct, you don't need that non-semantic, useless clearing div. All you need to do is stick an overflow:hidden
onto the container:
#sub-title { overflow:hidden; }
这篇关于如何将两个div水平放置在另一个div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!