shamim
shamim

Reputation: 6768

How to center one div in form

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?

Upvotes: 0

Views: 43640

Answers (3)

Stephen Mwanzia
Stephen Mwanzia

Reputation: 31

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

Upvotes: 1

Sandeep Pathak
Sandeep Pathak

Reputation: 10747

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>

Upvotes: 6

Mr Grok
Mr Grok

Reputation: 3956

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>

Upvotes: 2

Related Questions