我有这个标记:
我想使用
问题是
我希望标签看起来像这样(显示
可以吗?
label.required:after {
content: ' *';
color: red;
}
<label class="required">please enter your username</label>
text-overflow: ellipsis
来处理文本过长的标签,就像这样:
label {
display: inline-block;
max-width: 150px;
}
label.required:after {
content: ' *';
color: red;
}
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<label class="required ellipsis">please enter your username</label>
:after
伪元素也被截断了,因此没有*显示。我希望标签看起来像这样(显示
:after
伪元素):please enter your us... *
可以吗?
:after
,不需要改变伪元素。 - Temani Afifposition: relative;
是必需的。 - tom