Log in

View Full Version : Please help me with centering



nycguurl
06-26-2009, 04:43 AM
A nice guy on the DD forums gave me this code awhile back. It's so amazing, it helped me absolutely position elements inside a div. It's supposed to center the parent, and then the contents inside are absolutely positioned where I want. But for some reason, although the div centers perfectly in IE, it doesn't center in Firefox. Can you please help me? :( :confused: :o :p :eek:

This is in the HEAD section:

<style type="text/css">
.container1 {
position:relative;
width:275px;
height:658px;
margin:0 auto;
}
.abs_im {
position:absolute;
border:none;
}
#pic1 {
top:0;
left:0px;}
#pic2 {
top:534;
left:210;
}
</style>


This is in the BODY section:

<div class="container1">
<img class="abs_im" id="pic1" alt="" src="images/notepaper_1.png" width="384" height="658">
<a href="javascript:poptastic('get.html');"><img class="abs_im" id="pic2" alt="" src="images/clickme.gif" width="100" height="98"></a></div>

echristo66
06-26-2009, 02:54 PM
Centers for me, based on what you provided, do you have this div inside another div or some such? Could be a float issue?

nycguurl
06-26-2009, 06:05 PM
It wasn't centering. But wait, I figured it out. In the head section, I had the width of the div set smaller than the width of the biggest image inside it. I overlooked it because I had changed images to a wider one. I fixed it and it centers perfectly now in FF. Thanks for reading. Maybe someone else can benefit from the code. ;)

C55inator
06-28-2009, 04:37 PM
State that this is resolved, please.

thatsmybag
06-30-2009, 07:16 PM
try adding margin-left: auto; margin-right: auto;

that is usually what firefox expects