Jump to content

centering a DIV


scott33

Recommended Posts

How would i go about centering a div, i use topstyle for all of my HTML editing, the <center> tag works but not in all scenarios plus that tag isn't used anymore... and i don't think it works for DIVs... i have an absolute position on my content div that i want centered..heres my code.. i want the content class centered<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title></title></head><style type="text/css">body { background-color: black;}.content { background-color: white; width: 800px; height:900px; margin= 0px; top: 0px; position:absolute; background-position: center; text-align: center; }</style><body><div class="center" ></body></html>

Link to comment
Share on other sites

How would i go about centering a div, i use topstyle for all of my HTML editing, the <center> tag works but not in all scenarios plus that tag isn't used anymore... and i don't think it works for DIVs... i have an absolute position on my content div that i want centered..heres my code.. i want the content class centered<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title></title></head><style type="text/css">body { background-color: black;}.content { background-color: white; width: 800px; height:900px; margin= 0px; top: 0px; position:absolute; background-position: center; text-align: center; }</style><body><div class="center" ></body></html>
Hi,Have you tried using .center{ width:500px; left: 45%;}within this classyou can place your class which you want centered.
Link to comment
Share on other sites

If you stop using position:absolute; you can use a fixed width and margin:auto to center it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...