简体   繁体   中英

Targeting JSF 2.0 components in CSS

I'm developing my first project using JSF 2.0, so forgive me if this is a stupid question. However, I can't seem to find an answer to this question after Googling it.

Basically, I have a stylesheet which, as an example, adds this style:

body {
    padding-top: 60px;
}

This works fine if my HTML file uses the <body> tag, but doesn't work if I use <h:body> (assuming I import the JSF HTML taglib with the shortcut "h").

This is the same for any other components, which is a pain, especially when trying to style form components.

Any help would be very much appreciated. Thanks.

but doesn't work if I use <h:body> (assuming I import the JSF HTML taglib with the shortcut "h").

This is not true. JSF runs in webserver. JSF generates HTML. Webserver sends this HTML to browser. All the browser get is JSF-generated HTML, not JSF source code itself. CSS runs in browser only. All the CSS will work on is the JSF-generated HTML. Open the JSF page in browser, rightclick and View Source to see it yourself. The <h:body> has become <body> .

If you have a problem with your CSS, it's caused elsewhere. At least, you need to design your CSS based on the JSF-generated HTML output, not on the JSF source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM