【问题标题】:Align Form in PHP在 PHP 中对齐表单
【发布时间】:2016-02-17 10:00:13
【问题描述】:

如何将我创建的表单居中对齐?

$form = <<<END
<form method='post' action=''>
      Adresa IP host : <input type='text' name='host'><br><br>
      <input type='submit' name='submit' value='Connect'>
</form>
END;

echo $form;

$t = new TELNET();
if (!empty($_POST)){
   $host = $_POST['host'];
   echo("CONNECT:".$t->Connect($host, $name, $pass)."<br>");
   echo("LOGIN:".(int)$t->LogIn());
   echo("<br>Status Interfete:<br>");
  $interfaces_status = ($t->GetOutputOf("show interface status"));
foreach ($interfaces_status as $value) {
    echo "$value <br>";

我希望表单位于页面的中心。

【问题讨论】:

  • 我认为&lt;center&gt; 标签在大约十年前就已经被弃用了...... HTML 5 根本不支持它。 @Sougata
  • 它不在 HTML5 中。虽然有些风格会起作用。只是一个例子

标签: php css forms alignment


【解决方案1】:

在css中:

form {
    width: 800px;
    margin: auto;
}

【讨论】:

    【解决方案2】:

    您需要使用 css 完成此操作。请将表单放在一个 div 中,并根据 div 类应用 css。

    <div class="frmCntr">
    <form method='post' action=''>
          Adresa IP host : <input type='text' name='host'><br><br>
          <input type='submit' name='submit' value='Connect'>
    </form>
    </div>
    

    然后像这样在你的 css 文件中添加 css:

    .frmCntr{
    width:80%; margin:auto;
    }
    

    form {
        width:80%; margin:auto;
        }
    

    【讨论】:

      【解决方案3】:

      你可以使用margin:auto。

      <form method='post' action='' style='margin:auto'>
      

      如果您没有为表单设置宽度,则必须这样做才能在这种情况下使边距正常工作。

      <form method='post' action='' style='margin:auto; width:400px'>
      

      【讨论】:

      • 谢谢,你是最棒的!
      猜你喜欢
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多