对齐浮动按钮的HTML / CSS问题

时间:2015-06-03 09:36:40

标签: html css

我只需要帮助对齐接受/拒绝按钮。因为我用漂浮物:对;命令,取消按钮被抛到寄宿生的最右侧,我不知道如何正确对齐它。

<?php

echo'
<html>
<head>
<style>

p
{ 
    border: 1px solid black; 
    width: 22%; 
    text-align: left
}

label
{
    display: inline-block;
    float: left;
    clear: left;
    width: 300px;

    text-align: left;
    padding: 5px;
}

input 
{
  display: inline-block;
  float: right;
}  


left
{
float: left;
padding: 5px;
}

</style>
</head>
</html>';

$conn = mysqli_connect('localhost', 'root', 'admin', 'Users');
MYSQLI_SET_CHARSET($conn, "UTF8");

echo '
<FORM ACTION = "Script.php" METHOD = "POST">
    <div>
        <p> 
            <label>Username:    <input type = "TEXT" name = "ID">  </label>
            <br>
            <label>Name:          <input type = "TEXT" name = "name"></label>
            <br>
            <label>Surname:     <input type = "TEXT" name = "surname">  </label>
            <br>    
            <label>Address  <input type = "TEXT" name = "address"></label>
            <br>
            <left><input type = "submit" value = "Accept"></left>
            <input type = "submit" value = "Cancel">
            <br>
            <br>
            <br>
            <br>
            <br>
        </p>
    </div> 
</form>';

    if(ISSET($_POST["ID"])  && ISSET($_POST["name"])  && ISSET($_POST["surname"])  && ISSET($_POST["address"]))
    {
        $ID = mysql_real_escape_string ($conn, $_post["ID"]);
        $ime = mysql_real_escape_string ($conn, $_post["name"]);
        $priimek = mysql_real_escape_string ($conn, $_post["surname"]);
        $naslov = mysql_real_escape_string ($conn, $_post["address"]);

        MYSQLI_query ($conn, "insert into place ( ID, name, surname, address)
        VALUES (".$id." , ".$name." '.' ".$surname." , ".$address.")");

        if(MYSQLI_AFFECTED_rows($conn) ==0)
            ECHO "Information not added! ";
        else
            ECHO "Information successfully added! ";
    } 
?>

3 个答案:

答案 0 :(得分:2)

使用     div style =“clear:both;” 要么     div class =“clearifix”

每当你使用float css。

答案 1 :(得分:0)

添加

<div class="clearfix"></div>

之前

 <input type = "submit" value = "Cancel">
 <input type = "submit" value = "Accept">

答案 2 :(得分:0)

<div class="clear"></div>

在css中

.clear
{
clear:both;
}