开发者

Troubleshooting css background-image not loading

I have the code snippet below. I am expecting the div to have that background logo. It's not happening. All js files are loaded correctly as other parts of the page work fine.

Two questions:

1- Using a network sniffer I don't see a request for logo.png. Possible reas开发者_JAVA技巧ons why?

2- Is there a way to know what url path the browser is using without using a network sniffer? I wanted to know if I should use ./ or ../ or whatever for the correct full path.

<script type="text/javascript">

    $(document).ready(function() {
        $("#test").css("background-image", "SomeLongMultiLevelPath/logo.png" );
    });

</script>

<div id="test">
</div>


Try this:

$("#test").css("background-image", "url(SomeLongMultiLevelPath/logo.png)" );

... assuming your image path is right.


Yes, so it was as I said: url(SomeLongMultiLevelPath/logo.png) As for the directory, the dots are used to go up by one level:

//Home
// Dir1
//// Image.png url(../Dir1/image.png)
// Dir2
//// Yourpage.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜