我有一个<input>
元素,我无法修改其周围的HTML,但我想在其中添加一个glyphicon(<i class="glyphicons glyphicons-some-icon"/>
)。我希望能用CSS做到这一点,但我似乎无法使用:after
。我认为像下面这样会产生该元素:如何使用CSS:将Glyphicon元素添加到输入之后
#my-input {
content: attr(class, 'glyphicons glyphicon-some-icon');
content: '<i/>';
}
但它没有。谁能理解:after
更好地解释我如何使用:after
生成想要的<i class="glyphicons glyphicons-some-icon"/>
?
你不能。 ':之前'和':之后'伪元素插入元素内。 ''元素不能生孩子,因此不幸的是不能生孩子。 – misterManSam
你可以通过查看Bootstrap的样式表来找到这些: http://stackoverflow.com/questions/19740700/glyphicons-bootstrap-icon-font-hex-value –
这不可能与纯粹的CSS http://stackoverflow.com/ question/2587669/can-i-use-the-after-pseudo-element-on-an-input-field – NooBskie