H Ghuman H Ghuman - 1 month ago 4
CSS Question

I am trying to use image, stored in project directory (projectname/pictures/display_pic.jpg), through css background property

It shows up "cannot resolve file 'display_pic.jpg'". whats exact way to use the image stored in 'pictures' directory?? i was trying the line of code below:

background: url('../../pictures/display_pic.jpg');

Answer

If you are using google chrome, just go to developer view, inspect the element for which you are setting the background, and then in the styles for that element, hover over the "background: url()". It will show the generated path. From that you can tell if you are using too many "../" or you got the file path totally wrong. Other browsers too should have similar feature.