CSS浮动问题

时间:2014-07-01 22:17:36

标签: css

我遇到浮动财产问题。

我的代码:JSFiddle

我希望它看起来像这样:printscreen

我能做什么,我希望按钮不会像按钮上方的其他两个元素那样浮动。

我的css :(你可以在JSFiddle上看到我的HTML)

#upload_photo_form > p {
    margin: 3px;
}

#upload_one {
    width: 150px;
    height: 60px;
    background-image: url('image, doesnt matter, looke the same anyways');
    background-size: 100%;
    float: left;
    border: 1px solid grey;
    border-radius: 3px;
}

#upload_two {
    margin-left: 5px;
    width: 150px;
    height: 60px;
    background-image: url('image, doesnt matter, looke the same anyways');
    border: 1px solid grey;
    border-radius: 3px;
    background-size: 100%;
    float: left;
}

3 个答案:

答案 0 :(得分:1)

您可以按如下方式修改代码:

<div id="upload_photo_form">
    <div>
        <p>Please choose a file to upload.</p>
        <input id="upload_file" type="file" /><br>
   </div>
   <div>
        <p>Which mode would you like to use?</p>
        <div id="upload_one"></div>
        <div id="upload_two"></div>
   </div>

</div>
 <div style="clear:both;"></div>
 <button id="upload_button">Upload</button>

答案 1 :(得分:1)

试试这个:

#upload_button{
    margin-top:10px;
    clear: both;
}

DEMO

您也可以使用:

display: block;

答案 2 :(得分:0)

如果您只想使用CSS执行此操作:

#upload_photo_form div {overflow: hidden}
#upload_button {clear: both; margin-top: 10px;}