html - How to get the <h:graphicImage> in JSF automatically resize and fit into browsers window? -
given following snippet
<?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <title>mytitle</title> <h:outputstylesheet library="css" name="styles.css"/> </h:head> <h:body> <h:graphicimage name="images/mainbackground.jpg"/> </h:body> </html> i'd mainbackground.jpg resize automatically. following css file not resize it:
#mainbackground { width: auto; height: auto; } but if set width , height directly in h:graphicimage tag , comment out h:outputstylesheet like
<h:head> <title>mytitle</title> <!--<h:outputstylesheet library="css" name="styles.css"/> --> </h:head> <h:body> <h:graphicimage id="mainbackground" name="images/mainbackground.jpg" width="200" height="200"/> </h:body> </html> resizing works. how can use external css file working in java ee context? proper way this?
btw found tutorials using google , questions here on regarding embedding image solutions provided either didn't cover resizing or have not worked me.
iirc, jsf not output id h:graphicimage default, , if does, it's not 'mainbackground' nested id path:to:image.
set styleclass attribute on h:graphicimage , use .mainbackground (a css class selector), not #mainbackground (id selector). way @ least proper css selector.
furthermore, auto css default both width , height, therefore has no effect. want change actual values. see standard css reference texts or guides further details.
Comments
Post a Comment