使用CSS,我如何将类似于“►”的字符设置为HTML列表的标记?
在CSS中使用所需字符的十六进制值,如下所示:
ul li:before {
content: "\25BA"; /* hex of your actual character, found using CharMap */
}
< p > 注意: 这不适用于 IE < 8
< p > 示例: http://jsfiddle.net/mrchief/5yKBq/
< p > 要在项目符号后添加空格: content:"\25BA" " ";
ul {
list-style: disc url(bullet.gif) inside;
}
:before
上使用 margin-right
。 - mu is too short另外,如果您需要在IE<8中使用此功能,可以使用以下表达式:
UL LI:before,
UL LI .before {
content: "►"
/* Other styles for this pseudo-element */
}
/* Expression for IE (use in conditional comments)*/
UL LI {
list-style:none;
behavior: expression(
function(t){
t.insertAdjacentHTML('afterBegin','<span class="before">►</span>');
t.runtimeStyle.behavior = 'none';
}(this)
);
}
.js
文件中,这将成为解决IE中许多问题的好方法。 - kizu