简体   繁体   English

在下面的表格中对齐两个并排的div螺丝

[英]aligning two side-by-side divs screws up table below

I have two divs side by side. 我有两个div并排。 I want to align the contents of one to the left and the contents of the other to the right. 我想将其中一个的内容左对齐,将另一个的内容右对齐。 The left aligns properly but when I align the right, it screws up the input table just below. 左对齐正确,但是当我对齐右对齐时,它会拧紧下面的输入表。 (See image) (见图片)

This 这个 对

Sadly Becomes 可悲地成为

This 这个

错误

I feel like this is probably a really simple question but I just can't figure it out, though I swear I've done it before. 我觉得这可能是一个非常简单的问题,但我不能确定,尽管我发誓我以前做过。

Here's the html (I've removed some php loops in the middle of it because I doubt it's relevant but let me know if you think it is): 这是html(我在其中删除了一些php循环,因为我怀疑它是否相关,但如果您认为是这样,请告诉我):

    <div class='uppertitle'>
        <div class='question'><h4>What does {$business['name']} aim to achieve within the next three months?</h4></div>
        <div class='addRow'><input type="button" value="Add Goal" onclick="addRow('threemonths')" /></div>
    </div>
    <div class='goals_table'>
    <table id="threemonths" class= 'milestones' width="350px" border="1">

        <tr>
            <td class= 'deleteRow'><input type="button" name="Delete" onClick="newDelete(this);"/> </td>
            <td><input type="text" name="txt[]" value='{$goal['description']}'/><input type="hidden" name="type[]" value='threemonths'></td>
        </tr>

    </table>
    </div>

And here's the CSS: 这是CSS:

.addRow {
    float: right;
    display: inline;
}

div#goals .question {
    float: left;
    margin-left: 40px;
    display: inline;
}

.goals_table {
    display: block;
}

A sample of the element can be found here: https://dl.dropboxusercontent.com/u/11993667/Hosting%20Signup%20%7C%20%7C%20Page%2010.html 可以在此处找到该元素的示例: https : //dl.dropboxusercontent.com/u/11993667/Hosting%20Signup%20%7C%20%7C%20Page%2010.html

Thanks in advance. 提前致谢。

You are going to need this CSS on the table. 您将在桌子上需要此CSS。

clear: both

clear will prevent items from sitting on left , right or both the sides of an element. 明确将防止坐在物品leftrightboth元素的两侧。

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

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