How to center one div in form

别来无恙 提交于 2019-12-13 03:39:14

问题


I work on C# Asp.net

Main div ---- table

want to show this div on middle of the form.i want to build a login form.my table contain

User name:**(it's a lable,on browser it's broken like user
                                                       name : show why?)**
password:

<div id="main">

<table width="600px" border="1">
            <tr>
                <td>
<asp:Label ID="Label1" runat="server" CssClass="cssLabel" Text="User Name :"></asp:Label>
                </td>


                <td>
 <asp:Label ID="Label2" runat="server" CssClass="cssLabel" Text="Password :"></asp:Label>
                </td>
            </tr>
        </table>

</div>

want to show div on middle of the form? and why my lable text are going to broken how to solve it?

if u gone to google.com than you see text box take position on middle of the frame.i want this .i want my controls also take position on the middle of the frame.How to do that?


回答1:


You can use this to show idiv n the middle of the form:-

<div style="margin-left:auto;margin-right:auto;">Put the controls here </div>



回答2:


You've edited your question now so this doesn't give you the exact code you need, but would help you work it out / others who view your question with a similar problem. So here goes... you need something like this:

<style type="text/css">
    .wrp { width: 100%; text-align: center; }
    .frm { text-align: left; width: 500px; margin: auto; border: 1px solid black; }
    .fldLbl { white-space: nowrap; }
</style>

<div class="wrp">
    <div class="frm">
        <span class="fldLbl">User name:</span>
    </div>
</div>



回答3:


try this option, that is style the div with style="width:100%;text-align:center"



来源:https://stackoverflow.com/questions/3616112/how-to-center-one-div-in-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!