I'm new at VF develop. please help.
I loaded many image in VF like below, and it works well.
<apex:image alt="s01" title="s01" url="{!URLFOR($Resource.resource_images, '/s01.PNG')}"/>
However, currently I need load image in css file.
I searched many related articles and tried like below.
.qna {
background-image: url("{!URLFOR($Resource.resource_images, '/s01.PNG')}"); }
and it doesn't work..
Anybody know why it doesn't work?
Thanks in advance.
Best Answer
The syntax below:
will only be resolved when you use it directly in the markup on the Visualforce page. If you need to provide the image name in the CSS file, then you will need to utilize the relative path of the image in the CSS. The syntax in your case will be as:
For more details, refer to Referencing a Static Resource in Visualforce Markup documentation which details as how you can create a CSS with relative image path and utilize those on a VF page.
Excerpt below from the documentation: