更新:这是一个 jsFiddle。
我希望它看起来像这样:

...但它看起来像这样:

#container 水平居中,并且必须保持如此。似乎无法正确理解这一点...
UPDATE: Here's a jsFiddle.
I want it to look like this:

... but it looks like this:

The #container is horizontally centered, and must stay so. Can't seem to get this right...
发布评论
评论(2)
当您并排浮动盒子时,会发生这种情况,一个盒子在左边,另一个在右边,两个盒子的宽度都是
宽度:50%
。但内边距、边距和边框无意中增加了框的宽度,导致框宽度超过 50%,并迫使右侧框移动到前一个框下方。尝试为框设置静态宽度(需要计算)
http://jsfiddle.net/fuYYv/
this happens when you float boxes side by side, one box to the left, the other to the right, both having
width:50%
. But padding, margins and border unintentionally increase the width of the boxes causing them to be more than 50% and forcing the right box to move under the previous box.try setting static width to the boxes (will need calculation)
http://jsfiddle.net/fuYYv/
布莱恩唐宁的评论给了我一个线索。
我添加了
完美的作品。非常感谢你们这些向导:)
这对其他人应该有用。 jsFiddle 与答案。代码如下:
Bryan Downing in the comments gave me a clue.
I added
Works perfect. Big thanks to you wizards :)
This should be useful for others. jsFiddle with answer. Code below: