tags:

views:

44

answers:

2

I have an aspx Login control and I would like to center it on the screen.

How can i accomplish this? I've tried applying text-align: center on it.

+1  A: 

in CSS:

<div style="width: 200px; margin-left: auto; margin-right:auto;">
  <!-- contents will be contained in a box that is centered by its parent's box. -->
</div>

More info

Randolpho
the container div should contain a fixed with, and the margin should be 0 for top and bottom and auto for left and right, which logically should work, but still no luck as Login control gets rendered as a Table.
LB
+2  A: 
#containing_element { //Or body
    text-align: center; // For IE
}
#element_to_center {
    display: block;
    margin: 0 auto; // For everything else
    text-align: left; // Assuming you don't want everything else centered.
}
Sean Vieira
+1, although if you use IE-style, you have to use `text-align: left` on your contained/centered element otherwise the centered text alignment will be inherited.
Randolpho
@Randolpho Absolutely true -- thanks for the addition.
Sean Vieira