0

我使用 jQuery Validate 插件来突出显示错误。它用红色替换文本的颜色,这对于除一个 - 之外的所有元素都可以.help-block,它应该保持蓝色。

这是没有错误的代码:

<div class="control-group">
    <label class="control-label" for="place-of-birth">Place of birth</label>
    <div class="controls">
      <p class="help-block">Please input place of birth below, 2-80 symbols</p>
      <input type="text" class="input-xlarge" id="place-of-birth" name="place-of-birth" minlength="2" maxlength="80" autocomplete="off">
    </div>
</div>

这是错误消息:

<div class="control-group error"> <!-- STYLE IS CHANGED HERE -->
    <label class="control-label" for="place-of-birth">Place of birth</label>
    <div class="controls">
      <p class="help-block">Please input place of birth below, 2-80 symbols</p>
      <input type="text" class="input-xlarge" id="place-of-birth" name="place-of-birth" minlength="2" maxlength="80" autocomplete="off">
      <div class="help-block" generated="true" for="place-of-birth">Please enter at least 2 characters.</div> <!-- THIS LINE IS ADDED -->
    </div>
</div>

我试图用以下 CSS 覆盖它:

.control-group .error .help-block { color: blue; }

但这没有帮助。演示

这里有什么问题?

4

2 回答 2

1

像这样改变它:

.control-group.error .help-block { color: blue; }

如果一个元素上有两个类,则选择器之间不能有空格。如果有空格,则表示该类属于子标签。

于 2012-04-11T16:52:12.550 回答
0

CSS 规则是这样的:

.control-group.error .input-prepend .add-on, .control-group.error .input-append .add-on {
  color: #B94A48;
  background-color: #F2DEDE;
  border-color: #B94A48;
}

修改文件中的这些值bootstrap.css或自己创建。

于 2012-04-11T16:52:29.230 回答