开发者

CSS - use character for list marker

Using CSS, how can I set a character like "►" 开发者_StackOverflowas a list marker for an HTML list?


Use the hex value of the desired character in CSS like this:

ul li:before { 
   content: "\25BA";  /* hex of your actual character, found using CharMap */
}

Note: this will not work in IE < 8

Demo: http://jsfiddle.net/mrchief/5yKBq/

To add a space after the bullet: content: "\25BA" " ";
Demo

You can also use an image like this:

ul {
   list-style: disc url(bullet.gif) inside;
}


Also, if you need this in IE<8, you can use the following expression:

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)
    );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜