如何在html / css页面的中心对齐表单 [英] How to align form at the center of the page in html/css

查看:120
本文介绍了如何在html / css页面的中心对齐表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是html / css的新手。我正在努力建立自己的形式,并且试图将其与中心对齐。



Html代码:

 <!DOCTYPE HTML> 
< head>
< title>具有表单的网页< / title>
< link rel =stylesheettype =text / csshref =Form.css>
< / head>
< body>
< h1>建立新帐户< / h1>
< form>
< table>
< tr>
< td>名称:< / td> < td>< input type =textname =name>< / td>< br>
< / tr>
< tr>
< td>电子邮件:< / td> < td>< input type =textname =email>< / td>< br>
< / tr>
< tr>
< td>密码:< / td> < td>< input type =passwordname =pwd>< / td>< br>
< / tr>
< tr>
< td>确认密码:< / td> < td>< input type =passwordname =cpwd>< br>
< / tr>
< tr>
< td>< input type =submitvalue =Submit>< / td>
< / tr>
< / table>
< / form>
< / body>

Css代码:

  body 
{
background-color:#484848;
}
h1
{
color:#000000;
text-align:center;
font-family:SIMPSON;
}
表格
{
align:center;
}

我应该如何更改我的代码以对齐整个窗体? / p>

解决方案

演示



css

  body {
background-color:#484848;
保证金:0;
padding:0;
}
h1 {
color:#000000;
text-align:center;
font-family:SIMPSON;
}
表格{
width:300px;
margin:0 auto;
}


I am new to html/css. i am trying to build up my own form and i am trying to align it in the center. I used the align property in css but its not working.

Html code:

<!DOCTYPE HTML>
<head>
    <title>Web Page Having A Form</title>
    <link rel = "stylesheet" type="text/css" href="Form.css">
</head>
<body>
    <h1>Create a New Account</h1>
      <form >
       <table>
        <tr>
         <td>Name :</td> <td><input type="text" name="name"></td><br>
        </tr>
        <tr>
         <td>Email :</td> <td><input type="text" name="email"></td><br>
        </tr>
        <tr>
         <td>Password :</td> <td><input type="password" name="pwd"></td><br>
        </tr>
        <tr>
         <td>Confirm Password :</td> <td><input type="password" name="cpwd"><br>
        </tr>
        <tr>
         <td><input type="submit" value="Submit"></td>
        </tr>
       </table>
      </form>
</body>

Css Code:

    body
{
    background-color : #484848;
}
h1
{
    color : #000000;
    text-align : center;
    font-family: "SIMPSON";
}
form
{
    align:"center";
}

How should i change my code to align the entire form in the center?

解决方案

Like this

demo

css

    body {
    background-color : #484848;
    margin: 0;
    padding: 0;
}
h1 {
    color : #000000;
    text-align : center;
    font-family: "SIMPSON";
}
form {
    width: 300px;
    margin: 0 auto;
}

这篇关于如何在html / css页面的中心对齐表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆