How do you center divs using only CSS -


i use way center divs using table , css:

<table width="69" border="0" align="center">   <tr>     <td width="59">       <div style="position:relative;">         <div style="position:absolute; text-align:left; top: 100px;">div2 content goes here</div>         <div style="position:absolute;text-align:left;">div content goes here</div>       </div>     </td>   </tr> </table> 

here's sample: http://2slick.com/div_center.html

notice how expanding browser doesn't change centering of divs. know way similar using css , less code?

give div fixed width , set both left , right margins auto.

.centereddiv {     width: 800px;     margin-left: auto;     margin-right: auto; } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -