How to include image into css file using JSF tag


Tags: css,jsf,jsf-2

Problem :

I have this css file which sets background image into JSF page:

body { padding: 35px; background: #4c4c4c url(images/grad1.png) 0 0 repeat-x; color: #fff; font: 11px/normal Arial, Helvetica; }

I want to use this tag in order to include the image as JSF resource:

<h:graphicImage library="images" name="grad1.png" />

How I can include the image into the css file as JSF resource?



Solution :

Provided that your CSS file is loaded via <h:outputStylesheet>, use #{resource} mapping.

body {
    padding: 35px; 
    background: #4c4c4c url(#{resource['images/grad1.png']}) 0 0 repeat-x; color: #fff; 
    font: 11px/normal Arial, Helvetica;
}

    CSS Howto..

    How can I use jquery to hide a drop down menu when the user clicks outside of the menu area?

    Background hover showing in CSS

    How can I remove the generic HTML/CSS tooltip? [duplicate]

    In html how do I have table within table look visually the same as if I didnt have the inner table

    How to get `:after` to work in extjs iconCls?

    How do I use li:hover to change the WHOLE li color?

    How to keep css background image blurred inside a container?

    How to apply css mark on videogular time line at specific time

    How do I stretch a div to be the height of the document body, not the viewport? (included code)

    how to turn off the break word in css? [duplicate]

    How to get html elements from different class xpath?

    How to toggle visibility of 2 divs after clicking a mailto link?

    How to implement this to my index.html?

    How to prevent fixed positioned element overlapping others elements in css?

    How to use top middle and center inside a div

    How to get this div into the right position

    How to add css to Vaadin / Maven project?

    How to add an anchor tag to a block of html?

    How can I generate a random color with Stylus CSS?

    How Do I Make Large Quotation Marks Wrap Properly Around Quotations?

    How do I remove the gap between div tags?

    How to select span element inside multiple div classes and id's?

    How to remove the empty space between divs in CSS?

    How to CSS select each first div without class after div with class?

    How to locate Element via CSS Selector/XPath?

    Django Allauth - How to add custom css class to fields?

    How can I stop my CMS’s CSS affecting my content?

    How to change floating div's width to fill all the space they occupy?

    how to write set of styles as a function in compass sass

    ASP.NET MVC: How do other people apply conditional CSS classes?