我在将表单和按钮居中对齐时遇到问题,这是我的代码:
<body>
<h1 style="font-family:Comic Sans Ms;text-align:center;font-size:50pt;color:#ff00ba;">
You need to login :) </h1>
<form style="font-family:Comic Sans Ms; align:center;">
Username<br>
<input type="text" name="userid"/><br>
Password<br>
<input type="password" name="pswrd"/>
<br><br>
<input style="font-family:Comic Sans Ms;" type="button" onclick="check(form)" value="Login"/>
<input style="font-family:Comic Sans Ms;" type="reset" value="Cancel"/>
</form>
........
你可以看到我在表单样式中设置了“align:center”,但是没有用,表单和按钮仍然在网页的左侧,实际上,我试过div,它起作用了。但是,如果我不使用 div 并且我只想使用我当前的格式来设置对齐样式,有什么方法可以让它居中吗?干杯
使用文本对齐:居中;
JSFIDDLE
<body>
<h1 style="font-family:Comic Sans Ms;text-align:center;font-size:50pt;color:#ff00ba;">
You need to login :) </h1>
<form style="font-family:Comic Sans Ms; text-align: center;">
Username<br>
<input type="text" name="userid"/><br>
Password<br>
<input type="password" name="pswrd"/>
<br><br>
<input style="font-family:Comic Sans Ms;" type="button" onclick="check(form)" value="Login"/>
<input style="font-family:Comic Sans Ms;" type="reset" value="Cancel"/>
</form>
我是一名优秀的程序员,十分优秀!