asp.net web中如何使控件在页面的中间位置?高手帮忙!初学web
这是我写的代码,不知道在哪里写,写些什么代码可以使这些处在页面的中间部分?高手教教我怎么写,先谢了!<body><formid="form1"runat="server"...
这是我写的代码,不知道在哪里写,写些什么代码可以使这些处在页面的中间部分?高手教教我怎么写,先谢了!<body>
<form id="form1" runat="server">
<div>
<p runat="server" id="FristP">
<asp:Label ID="NameLabel" runat ="server" Text="用户名:"/>
<asp:TextBox ID ="NameTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="NameTextBox"
ErrorMessage="*">用户名不能为空</asp:RequiredFieldValidator></p>
<p runat ="server" id="SecondP">
<asp:Label ID="PasswordLabel" runat ="server" Text="密 码:"/>
<asp:TextBox ID ="PasswordTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="PasswordTextBox"
ErrorMessage="*">密码不能为空</asp:RequiredFieldValidator></p>
<p runat="server" id = "ThridP">
<asp:Button ID="btnSubmit" runat ="server" Text ="提交" OnClick="btnSubmit_Click" />
<asp:Button ID="btnCancel" runat ="server" Text ="取消" />
</p>
</div>
</form>
</body> 展开
<form id="form1" runat="server">
<div>
<p runat="server" id="FristP">
<asp:Label ID="NameLabel" runat ="server" Text="用户名:"/>
<asp:TextBox ID ="NameTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="NameTextBox"
ErrorMessage="*">用户名不能为空</asp:RequiredFieldValidator></p>
<p runat ="server" id="SecondP">
<asp:Label ID="PasswordLabel" runat ="server" Text="密 码:"/>
<asp:TextBox ID ="PasswordTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="PasswordTextBox"
ErrorMessage="*">密码不能为空</asp:RequiredFieldValidator></p>
<p runat="server" id = "ThridP">
<asp:Button ID="btnSubmit" runat ="server" Text ="提交" OnClick="btnSubmit_Click" />
<asp:Button ID="btnCancel" runat ="server" Text ="取消" />
</p>
</div>
</form>
</body> 展开
展开全部
1.可以使用div布局,设置边距来居中。
2.这里教你个简单的方法直接在form后加上<center>Tag就行了,末尾加</center>
<form id="form1" runat="server">
<center>//加入
<div>
<p runat="server" id="FristP">
<asp:Label ID="NameLabel" runat ="server" Text="用户名:"/>
<asp:TextBox ID ="NameTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="NameTextBox"
ErrorMessage="*">用户名不能为空</asp:RequiredFieldValidator></p>
<p runat ="server" id="SecondP">
<asp:Label ID="PasswordLabel" runat ="server" Text="密 码:"/>
<asp:TextBox ID ="PasswordTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="PasswordTextBox"
ErrorMessage="*">密码不能为空</asp:RequiredFieldValidator></p>
<p runat="server" id = "ThridP">
<asp:Button ID="btnSubmit" runat ="server" Text ="提交" OnClick="btnSubmit_Click" />
<asp:Button ID="btnCancel" runat ="server" Text ="取消" />
</p>
</div>
</center>//加入
</form>
2.这里教你个简单的方法直接在form后加上<center>Tag就行了,末尾加</center>
<form id="form1" runat="server">
<center>//加入
<div>
<p runat="server" id="FristP">
<asp:Label ID="NameLabel" runat ="server" Text="用户名:"/>
<asp:TextBox ID ="NameTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="NameTextBox"
ErrorMessage="*">用户名不能为空</asp:RequiredFieldValidator></p>
<p runat ="server" id="SecondP">
<asp:Label ID="PasswordLabel" runat ="server" Text="密 码:"/>
<asp:TextBox ID ="PasswordTextBox" runat="server" Text= "" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="PasswordTextBox"
ErrorMessage="*">密码不能为空</asp:RequiredFieldValidator></p>
<p runat="server" id = "ThridP">
<asp:Button ID="btnSubmit" runat ="server" Text ="提交" OnClick="btnSubmit_Click" />
<asp:Button ID="btnCancel" runat ="server" Text ="取消" />
</p>
</div>
</center>//加入
</form>
追问
现在是这样的,如何让用户名,密码上下右对齐,及那后面的两个文本框也是居中对齐呢?
追答
建一个2行2列的表格table将用户名和密码放在第一列的中设置css样式居中,然后将文本框放入第二列也居中就行了。如果你想按钮也对齐就3行吧。
或者你用div自己好好调节下,边距什么的也行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在div里添加<div style=" width: 1004px;" align="center">定义div固定宽1004px,align为居中
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
body 的margin-left:auto;margin-right:auto padding-left=auto; padding-right=auto
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询