Thu, 2012-02-16 06:54
I have been playing with converting my websites to fixed width css layouts from table layouts but I am having trouble centering my container div. I have found countless tutorials on the subject but I must be over looking something simple. Very frustrating!
here is my code for my test page.
Please tell me what I am doing wrong.
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- #container { background-color: #00FF00; margin: 0px; padding: 0px; position: relative; left: 0px; top: 50px; right: 0px; bottom: 0px; height: 1000px; width: 955px; text-align: left; } body { text-align: center; position: absolute; } --> </style> </head> <body> <div id="container"> Test Text </div> </body> </html>
Fri, 2012-02-17 11:32
#1
use this code. it is useful
use this code. it is useful for you.
<style type="text/css"> <!-- body{ padding:0; margin: 0 auto; width:1000px; } #container { background-color: #000; padding:20px; color:#fff; text-align:center; }--> </style> </head> <body> <div id="container"> Test Text </div>