scott33 Posted November 17, 2008 Share Posted November 17, 2008 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 More sharing options...
pcadv Posted November 17, 2008 Share Posted November 17, 2008 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 More sharing options...
jlhaslip Posted November 17, 2008 Share Posted November 17, 2008 You can't centre an absolutely positioned item.One or the other, not both. Link to comment Share on other sites More sharing options...
scott33 Posted November 17, 2008 Author Share Posted November 17, 2008 that doesnt work... with the left at 45% i use topstyle and the preview puts it almost to the end is there a property i can use to center it... Link to comment Share on other sites More sharing options...
Synook Posted November 17, 2008 Share Posted November 17, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.