我想有一个文本框在中心。我尝试了下面的代码。但它并没有把它放在中心位置。输出的图像也可以在下面找到。请通过在我的代码中指出错误来帮助我。如何在中心使用保证金属性在中心Div元素
<html>
<head>
<style>
#form
{
margin-top:40%;
margin-left:40%;
}
</style>
</head>
<body>
<div id="form">
<form method = "post" action = "test.htm" >
UserName: <input type="text" name = "username" />
</form>
</div>
</body>
</html>
我从上面的代码输出为:
设置'margin:0 auto;' –
检查下面的答案。 - @Abhinav – Nitesh