471,599 Members | 977 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

How Do I Center a Background Image in Firefox?

9
Please tell me how I center a background image in Firefox (2.0.0.7)?

The following code places any image in the top part of the browser:

body
{
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: center center;
background-image: url(url)
}

Thank you very much.
Oct 13 '07 #1
3 1676
drhowarddrfine
7,435 Expert 4TB
The same way you center an image in all standard browsers.
Does this page have any content? Or are you giving the body a height?
Oct 13 '07 #2
vps
9
The page does have content, but this sheet places background image incorrectly even on a blank page in Firefox and Opera (v. 9.23):

<style type="text/css">
body
{
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: center center;
background-image: url(http://www.thescripts.com/images/logo4.gif)
}
</style>

Internet Explorer (v. 7.0.5730.11) shows the image as expected though.
Oct 14 '07 #3
drhowarddrfine
7,435 Expert 4TB
Never, ever use Internet Explorer as an example of something that works. It is old, buggy and non-standard.

Showing the CSS is only half the picture. Need to see the html. Your css is working as expected in Firefox for me.
Oct 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

40 posts views Thread by Mark | last post: by
roula
19 posts views Thread by roula | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.