We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

luman on 08/05/06


Tagged

div center align


Versions (?)


Who likes this?

26 people have marked this snippet as a favorite

designerd
meth
gardano
panatlantica
szsk
damarev
px
Krullies
pckujawa
zensir
visualAesthetic
banjomamo
tavo
jacksont123
icarus
manub
fael
tidbit
rich13
vali29
starprojector
Wizzle
joellevin
Baris
isaac
SpinZ


Horizontal-Vertical div align


Published in: CSS 


  1. #mydiv {
  2. position:absolute;
  3. top: 50%;
  4. left: 50%;
  5. width:350px;
  6. height:300px;
  7. margin-top: -150px; /*set to a negative number 1/2 of your height*/
  8. margin-left: -175px; /*set to a negative number 1/2 of your width*/
  9. border: 2px solid #2982C6;
  10. background-color: #FFF;
  11. text-align: center;
  12. }

Report this snippet 

You need to login to post a comment.