如何填写空白以显示我的图像?

时间:2011-03-03 21:44:56

标签: html css jsf

<h:inputText id="email"
    value="#{user.user.email}"
    title="Email"
    onchange="this.form.submit()"
    required="true" requiredMessage="_____">
<f:validator validatorId="checkvalidemail"/>
</h:inputText>
<h:message for="email" styleClass="error"/>

验证

String enteredEmail = (String)object;
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
Matcher m = p.matcher(enteredEmail);
boolean matchFound = m.matches();    

if (!matchFound) {
FacesMessage message = new FacesMessage();
message.setSummary("____");
throw new ValidatorException(message);

和css

.error {
background-image: url('includes/style/delete2.png');
text-align: left;
font-size: 36px;
}

非常感谢你 最好的祝福 伊格纳西奥

1 个答案:

答案 0 :(得分:1)

<h:message>呈现HTML <span>,其维度取决于节点值。如果什么也没有,那么它将简单地崩溃,你将看不到CSS background-image。您需要将其设为具有固定大小的block级别元素。

.error {
    display: block;
    width: 36px;
    height: 36px;
    background-image: url('includes/style/delete2.png') no-repeat;
}

如果您想将其保持在同一行,请在必要时添加float: left;