HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Centering horizontal and vertical
Post new topic   Reply to topic    HTML Help Forum -> Member Tutorials
View previous topic :: View next topic  
Author Message
sticks464



Joined: 31 Dec 2006
Posts: 2625

PostPosted: Mon Dec 08, 2008 6:43 am     Centering horizontal and vertical Reply with quote

Most commonly used for centering flash content but will work with text and other elements.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
html{height:100%}
html,body {margin:0;padding:0;}
body{
   background:#ff6f02;
   text-align:left;
   min-width:650px;
   
}
#container{
   position:absolute;
   top:50%;
   margin-top:-200px;/* half content height*/
   left:0;
   width:100%;
}
#content {
   width:624px;
   margin-left:auto;
   margin-right:auto;
   height:395px;
   background:#666;
}
h1 {color:#fff;margin:0;padding:0}

</style>
</head>

<body>
<div id="container">
  <div id="content">
    <h1>Text goes here</h1>
  </div>

</div>
</body>
</html>
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> Member Tutorials All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial