我想在下面的表单代码中将'*'的颜色更改为红色,以便它们更突出。到目前为止,我还没有找到一种简单的方法来做到这一点。 ,自定义标签在表单中不起作用。
<form name="requestForm" action="requestSent.cshtml" onsubmit="return validateRequest()" method="post">
<label>Email Address: *</label><br>
<input type="text" name="customerEmail" /><br><br>
<label>First Name: *</label><br>
<input type="text" name="firstName" /><br>
<label>Last Name: </label><br>
<input type="text" name="lastName" /><br><br>
<label>Phone Number: </label><br>
<input type="text" name="phoneNumber" /><br><br>
<label>Request: *</label><br>
<textarea name="customerRequest" cols="40" rows="4"></textarea>
<p><input type="submit" value="Submit" /></p>
<br>
* Required Fields
答案 0 :(得分:3)
为您的所有*
添加一个范围。
<label>Email Address: <span class="red">*</span></label><br>
然后在你的CSS中:
<style type="text/css">
.red{
color: red;
}
</style>
答案 1 :(得分:2)
只需将*放入span标记并将css应用于
HTML
<label>Email Address: <span class="redSpan">*</span></label>
CSS
.redSpan { color:#F00;}
答案 2 :(得分:1)
尝试将*包装在span
中,然后为其应用css规则
e.g。
.someclass {
color: red;
}
答案 3 :(得分:1)
试试此代码
<style type="text/css">
.required{color:red;}
</style>
<form name="requestForm" action="requestSent.cshtml" onsubmit="return validateRequest()" method="post">
<label>Email Address: <span class="required">*</span></label><br>
<input type="text" name="customerEmail" /><br><br>
<label>First Name: <span class="required">*</span></label><br>
<input type="text" name="firstName" /><br>
<label>Last Name: </label><br>
<input type="text" name="lastName" /><br><br>
<label>Phone Number: </label><br>
<input type="text" name="phoneNumber" /><br><br>
<label>Request: <span class="required">*</span></label><br>
<textarea name="customerRequest" cols="40" rows="4"></textarea>
<p><input type="submit" value="Submit" /></p>
<br>
<span class="required">*</span> Required Fields