简体   繁体   English

在CSS中定位JSF 2.0组件

[英]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. 我正在使用JSF 2.0开发我的第一个项目,所以如果这是一个愚蠢的问题请原谅我。 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"). 如果我的HTML文件使用<body>标记,这可以正常工作,但如果我使用<h:body>则不起作用(假设我使用快捷键“h”导入JSF HTML taglib)。

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"). 但如果我使用<h:body>则无效(假设我使用快捷键“h”导入JSF HTML taglib)。

This is not true. 事实并非如此。 JSF runs in webserver. JSF在webserver中运行。 JSF generates HTML. JSF生成HTML。 Webserver sends this HTML to browser. Web服务器将此HTML发送到浏览器。 All the browser get is JSF-generated HTML, not JSF source code itself. 所有浏览器get都是JSF生成的HTML,而不是JSF源代码本身。 CSS runs in browser only. CSS仅在浏览器中运行。 All the CSS will work on is the JSF-generated HTML. 所有CSS都将使用JSF生成的HTML。 Open the JSF page in browser, rightclick and View Source to see it yourself. 在浏览器中打开JSF页面,右键单击并查看源代码以自行查看 The <h:body> has become <body> . <h:body>已成为<body>

If you have a problem with your CSS, it's caused elsewhere. 如果您的CSS出现问题,则会导致其他问题。 At least, you need to design your CSS based on the JSF-generated HTML output, not on the JSF source code. 至少,您需要基于JSF生成的HTML输出而不是JSF源代码来设计CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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