<pedrocorreia.net ⁄>
<mySnippets order="rand" ⁄> <mySnippets order="rand" ⁄>

 
<myContacts ⁄> <myContacts ⁄>

<email ⁄>


pc@pedrocorreia.net

<windows live messenger ⁄>


pedrojacorreia@hotmail.com

<myCurriculum type="pdf" ⁄>


Download
 
<myBlog show="last" ⁄> <myBlog show="last" ⁄>

 
<myNews show="rand" ⁄> <myNews show="rand" ⁄>

 
<myNews type="cat" ⁄> <myNews type="cat" ⁄>

 
<myQuote order="random" ⁄> <myQuote order="random" ⁄>

 
<myPhoto order="random" ⁄> <myPhoto order="random" ⁄>

<pedrocorreia.net ⁄>
 
<myAdSense ⁄> <myAdSense ⁄>

 
<myVisitorsMap ⁄> <myVisitorsMap ⁄>

 
 

<Centrar Div Horizontal e Verticalmente ⁄ >




clicks: 2753 2753 2007-12-02 2007-12-02 goto mySnippets mySnippets css  Download  Bookmark This Bookmark This


Subscribe Snippets RSS  Subscribe Snippets Updates by E-mail


Este é apenas uma (das muitas) maneiras para podermos centrar um Div (tanto horizontal como verticalmente) da janela do browser, em principio dá em qualquer tipo de resolução, pois vai-se adaptando à dimensões da mesma.

Para que funcione correctamente terão de ser usadas dimensões fixas (width e height) no #container.

- style.css
  1. #container{
  2. position: absolute;
  3. left: 50%;
  4. top: 50%;
  5. width: 250px;
  6. height: 275px;
  7. text-align: justify;
  8. }
  9. #box{
  10. position: absolute;
  11. left: -50%;
  12. top: -50%;
  13. width: 100%;
  14. height: 100%;
  15. }



  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <link rel="stylesheet" type="text/css" href="style.css" media="all">
  6. </head>
  7. <body>
  8. <div id="container">
  9. <div id="box">
  10. Lorem Ipsum is simply dummy text of the printing and typesetting
  11. industry. Lorem Ipsum has been the industry's standard dummy text
  12. ever since the 1500s, when an unknown printer took a galley of type
  13. and scrambled it to make a type specimen book. It has survived not
  14. only five centuries, but also the leap into electronic typesetting,
  15. remaining essentially unchanged. It was popularised in the 1960s with
  16. the release of Letraset sheets containing Lorem Ipsum passages, and
  17. more recently with desktop publishing software like Aldus PageMaker
  18. including versions of Lorem Ipsum.
  19. </div>
  20. </div>
  21. </body>
  22. </html>




Não sei até que ponto isto será uma forma "católica", vulgo standard de fazer ^_^ pois recorro a margens negativas.


Qualquer erro/ dúvida é só dizer!



Subscribe Snippets RSS  Subscribe Snippets Updates by E-mail





clicks: 2753 2753 2007-12-02 2007-12-02 goto mySnippets mySnippets css  Download  Bookmark This Bookmark This