html - Center a div both horizontal and vertical having a width in % -


i have login page , want center both horizontally , vertically. have written code it's not working.

html:

 <div class='loginmaindiv'>   <div class="logintable">   </div> </div> 

css:

.loginmaindiv {     height:550px;     width:100%;     text-align:center; }  .logintable {    display: block;   margin-left: auto;   margin-right: auto; } 

this example of can do:

http://jsfiddle.net/jun83/

play around margin of .logintable until fits requirements.

used css:

.loginmaindiv {     height: 550px;     text-align:center;     background: #ffdddd; /* clarity */ } .logintable {     width: 75%;     margin: 50% auto;     background: #ddddff; /* clarity */ } 

both background: #... statements can deleted without consequences.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -