开发者

How to add CSS to struts2 tags

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 fo开发者_开发知识库r setting CSS rules to struts2 UI components.


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.

 <s:checkbox cssClass="mycheckbox" label="checkbox test" name="checkboxField1" value="aBoolean" fieldValue="true"/>

and

  <style>
      .mycheckbox{
        /* Your style here */
      }

  </style>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜