Here user.name=...">

How to change textbox label color in Struts 2

I am stuck in changing font color

<s:textfield name="name" key="user.name"/> 

Here user.name=Usercomes from a bundle of resources. This way the label User Nameand text box are displayed on the JSP HTML page , but I want to change the font of the label User Name.

+4
source share
4 answers

You can do this using the CSS attribute selector. Give your <s:textfield>id and specify that id in CSS as follows:

<style type="text/css">
  label[for="nameFieldId"] {
    color: red;
  }
</style>

<s:textfield id="nameFieldId" name="name" key="user.name"/>

This will work because the theme xhtmlgenerates <label>for the tag <s:textfield>with the attribute for.

+1
source

Can you try under the code

<s:label value="user.name" cssStyle="color: #ffffff;"/>
<s:textfield name="name" required="true"/>

Struts . http://www.mkyong.com/struts2/working-with-struts-2-theme-template/ ( )

0

1. :

<s:textfield  id="tf1"  size="150%" />

2. , :

<s:label  for="tf1" style="font-family:Arial;color: #af2d2d" value="my textfield"/>                             

, !

0

<s:testfield>, ? ,

<s:testfield name="name" key="user.name" style="color:red;"/>

<span style="color:red;">
  <s:testfield name="name" key="user.name" style="color:red;"/>
</span>

. , .

-1

Source: https://habr.com/ru/post/1537673/


All Articles