Java 如何将 CSS 添加到 struts2 标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2395070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add CSS to struts2 tags
提问by Anand
I am using struts2 to build a web application and I use struts2 tags extensively. I am not able to apply CSS
styles to my struts2 textfields
, buttons
, labels
etc. What is the trick for setting CSS
rules to struts2 UI components.
我正在使用 struts2 构建一个 Web 应用程序,并且我广泛使用 struts2 标签。我不能申请CSS
样式我的struts2 textfields
,buttons
,labels
等什么是设置的伎俩CSS
规则Struts2的UI组件。
采纳答案by Vincent Ramdhanie
The struts2 tags have two attributes that are used for this, the cssClass and the cssStyle attributes. The cssClass attribute takes the name of a class that you create in your CSS file. The cssStyle attribute take a string representing CSS style. E.g.
struts2 标签有两个用于此的属性,cssClass 和 cssStyle 属性。cssClass 属性采用您在 CSS 文件中创建的类的名称。cssStyle 属性采用表示 CSS 样式的字符串。例如
<s:checkbox cssClass="mycheckbox" label="checkbox test" name="checkboxField1" value="aBoolean" fieldValue="true"/>
and
和
<style>
.mycheckbox{
/* Your style here */
}
</style>
回答by Sharmi
The elements of a struts2 form get its own class or id name. For example when the whole form gets converted into HTML table tag, the table tag gets a class name 'wwFormTable'. You can check the same in Firebug and apply css to those generated classes or ids.
struts2 表单的元素获得它自己的类或 id 名称。例如,当整个表单被转换成 HTML 表格标签时,表格标签会获得一个类名“wwFormTable”。您可以在 Firebug 中检查相同的内容并将 css 应用于那些生成的类或 id。