PDA

View Full Version : My div won't position right


gpopguru
05-09-2004, 01:14 AM
First of all, I want to ask if the <center> tag is a deprecated tag. If it isn't then I can just use that and don't have to worry about the rest of this.

I'm trying to convert my site to a CSS layout, and I'm having a problem with the positioning of a div within a div. I want the first div to be centered on the screen, but have the text aligned left. The inside div should be the same. It should be centered within the first div, but with the text left-aligned. I tried to use position: absolute, but it makes my div float in front of the rest of the text on my page. I played around with relative, static, and fixed, but they either work on one page but another or they just don't work at all. What's worse, it seems that if it works on some pages in Mozilla, it won't work at all in IE or vice versa.

The page is at www.mygpop.net/Art/index.php and the here's the part of the stylesheet in question.

#list {
border: none;
background: #E5E5E5;
color: #369;
text-align: left;
position: absolute; left:20%; right: 20%;
float: none;
margin: 0.5em;
width: 60%;
}

I tried messing around with the float property, too, but I'm not sure how to work that.

Anyone know what to do? Maybe I should just stick to <center>...

ronaldb66
05-10-2004, 12:37 PM
Centering a block level element - like a div, by default - can normally be accomplished by setting its left and right margins to "auto" and setting a specific width; since IE doesn't conform, the text-align property can be used on the containing element, which IE incorrectly applies to block level elements as well. Text alignment will likely need to be adjusted for the content of the div.
And, yes, the center element is deprecated in favour of using CSS.