【发布时间】:2014-07-21 14:01:19
【问题描述】:
我有无法更改的 html 代码。 我无法使用 JS 寻求帮助。所以唯一的选择是CSS。这里的例子: https://jsfiddle.net/4gKPL/
HTML:
<!-- code for input -->
<div class="form-group complete">
<label>label for text input</label>
<input type="text"/> <span class="error-message">This is an error message</span>
</div>
<!-- code for dropdown -->
<div class="form-group complete">
<label>label for select input</label>
<div class="custom-selectbox custom-selectbox-form">
<select name="sth" required>
<option>a</option>
<option>b</option>
<option>c</option>
<option>d</option>
</select> <span class="selectedValue"> </span>
<span class="is-visually-hidden">select to open the list</span>
</div> <span class="error-message">This is an error message</span>
</div>
CSS:
.complete:after {
content:'OK';
}
我需要为输入字段显示额外的内容(在本例中为“OK”),而不是为选择。
交互组件后的跨度是可选的,因此不必存在。
知道如何定义这个选择器吗?
【问题讨论】:
-
你不能在 `input' 元素上使用伪元素。
标签: css input pseudo-element