I am using a image as a background. Here is the CSS for the div
#bkground {
width: 1100px;
margin-left: auto;
margin-right: auto;
background: url(images/carbon_fiber2.jpg开发者_如何学Python) ;
background-repeat: no-repeat;
background-position: center top;
/*background: black;*/
}
In firebug it shows up as
#bkground {
background: url("images/carbon_fiber2.jpg") no-repeat scroll center top transparent;
margin-left: auto;
margin-right: auto;
width: 1100px;
}
Where does the tranparent setting come from and how can I have the image show up properly?
Thanks
Definitely a bad path, the image shows it to be at http://www.racefightclub.com/dev/css/images/carbon_fiber2.jpg
it should be http://www.racefightclub.com/dev/images/carbon_fiber2.jpg
so either make it ../images/carbon_fiber2.jpg
or probably /dev/images/carbon_fiber2.jpg
And this is because you are referencing the image path from within your css folder.
I think the transparent bit, is referring to the background colour, you can have a colour (as a backup if the image isn't found) and an image. Firebug is just adding the defaults that are applied that you haven't overriden. And the default for background-color is transparent. The image should still show up though if it's found, so I'm guessing it's not and instead the transparent background-color is being shown.
First thing I notice is that your image url is not in quotation marks in the css. I'd try that first.
So,
background: url('images/carbon_fiber2.jpg') ;
See comments, I've been reliably informed that quotes are not required.
Then, just a hunch, but are you including the css from a page on the root directory of your site? If not, you may need to make the path absolute, i.e.
background: url('/images/carbon_fiber2.jpg') ;
精彩评论