gpt4 book ai didi

HTML 居中表单

转载 作者:太空宇宙 更新时间:2023-11-03 19:32:24 25 4
gpt4 key购买 nike

我无法将以下表格居中:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Pages.css">
<title>Sign Up</title>
</head>
<body>
<form action="Actions/NewUser.jsp">
<fieldset>
<legend>Create A New User</legend>
<label for="usr">Username:</label>
<input type="text" name="usr" >
<br>
<label for="passwd">Password:</label>
<input type="password" name="passwd" >
<br>
<input type="submit" value="Register" >
<br>
<a href="log__in.html">Already Have An Account?</a>
</fieldset>
</form>
</body>
</html>

CSS:

fieldset {
background-color: #F5F6CE;
display: inline;
padding: 2px;
border: double #FF0000;
}

legend {
border: 1px #FF0000;
font-size: 14pt;
padding-left: 1em;
padding-right: 1em;
}

input [type = "submit"] {
color: #FF0000;
}

body {
background-color: #F5F6CE;
}
.center{
margin:0 auto;
display:inline;
}

我运行并刷新,但表格没有居中。我不是 HTML 开发人员,我只是为了紧急情况需要做一些工作。有没有办法让整个字段集和表单居中?

最佳答案

body {
background-color: #F5F6CE;

text-align:center;
}

fieldset {
background-color: #F5F6CE;
display: inline;
padding: 2px;
border: double #FF0000;

text-align:left;
}

text-align:center for body 标签居中你的表单

http://jsfiddle.net/R6V4E/1/

如果你想让表格垂直和水平居中,如下给出表格的位置和大小;

form {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
margin:auto;
width:250px;
height:130px;
}

http://jsfiddle.net/R6V4E/5/

关于HTML 居中表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23914330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com