简体   繁体   English

如何用div标签在三列之间划分空间?

[英]How to divide the space between three columns with div tag?

I have created three columns like this: 我创建了三列,如下所示:

<div style="float: left">Left Column</div>
<div style="float: left">Middle Column</div>
<div style="float: left">Right Column</div>

This works well on its own. 它本身可以很好地工作。 However the moment I add it to my Wordpress page template, by defining a left and right column around the existing main column something unexpected happens: 但是,当我将其添加到Wordpress页面模板时,通过在现有主列周围定义左右列,会发生意外情况:

http://venuscloud.com/crm-software/ http://venuscloud.com/crm-software/

The left column is correctly placed and the middle column is as expected in the middle but the right column is at the bottom. 正确放置了左列,中间列按预期放置在中间,而右列则放置在底部。 I don't understand why the remaining space is not divided between the three columns as expected. 我不明白为什么剩余空间没有按预期在三列之间分配。

Any comments? 任何意见?

Many Thanks, 非常感谢,

我目前无法测试,但我猜想是您在div上设置了填充或边距,这会使三个部分的总宽度大于100%。

The problem with your divs are. 您的div存在问题。 The right and left divs have css floats. 左右div都有css浮点数。 But your middle div doesn'r have that attributes. 但是您的中级div没有该属性。 Its keep on middle with margin-attributes. 它的边距属性居中。 Even giving float to middle div won't help you. 即使给float中间div也无济于事。 Because then you have to make the op divs correct. 因为那样,您必须使op div正确。

One method you can do is, change your divs order like : 您可以执行的一种方法是,更改div的顺序,例如:

<div id="left_column"></div>
<div id="right_column"></div>
<div class=​"col-full"></div>

then add float:right to your right-column div . 然后将float:right添加到right-column div

Hope this helps you :) 希望这对您有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM