Forum Moderators: not2easy

Message Too Old, No Replies

centreing image in external css

         

sparkiii

8:38 pm on Oct 18, 2010 (gmt 0)

10+ Year Member



I have a small repeating image at the top of the page that is currently at 100% width but I want to call it in to 953px width and centre it in any browser. Obviously the width is easy but I cannot get it to centre, it stays off to the side. The line currently looks like this

#all_top{ background:url(images/all_top.png) repeat-x right top; width:100%; height:40px;position:absolute; margin-bottom:-5px;z-index:1;}


This will probably answer its self after I find out about the other but this is the same look at the bottom of the page, but is just a band of colour made without an image?


#all_bottom{background:#603604; width:100%; height:27px;position:absolute; bottom:0px;}

Both these codes are on one line in the sheet.

Thanks

Nat

Major_Payne

12:36 am on Oct 19, 2010 (gmt 0)



You can not center anything when you use absolute positioning unless you tweak the other positioning properties. To center you also must use less than 100% width.


#all_top {
width:950px;
height:40px;
margin: 0 auto; /* centers container */
margin-bottom:-5px;
background:url(images/all_top.png) repeat-x right top scroll;
}



#all_bottom {
width:90%;
height:27px;
margin: 0 auto;
background:#603604;
}

sparkiii

1:20 am on Oct 19, 2010 (gmt 0)

10+ Year Member



Thanks Major_Payne, That works great, just had to adjust a few padding issues and it is all sitting nicely. Thank you very much for your help.