[英]Use · instead of bullet for <ul>
I found an article on the list-style-type property in CSS, but it doesn't list the · 我在CSS中找到了关于list-style-type属性的文章,但它没有列出&middot; (·) as an option, as opposed to the default disc
or • (·)作为选项,而不是默认disc
或&bullet; (•). (•)。 Is there a way to do this with HTML or CSS? 有没有办法用HTML或CSS做到这一点?
CSS (works in any browser supporting :before
and content:
): CSS(适用于任何支持:before
和content:
:)的浏览器:
li:before {
content: '\b7\a0'; /* \b7 is a middot, \a0 is a space */
}
li {
list-style:none;
text-indent:-.5em; /* helps make it look more like it's a bullet. */
}
Caution: It is not a real list style. 警告:这不是真正的列表样式。 Therefore, when you have wrapped lists, it will look funny. 因此,当你有包装列表时,它看起来很有趣。 This can perhaps be mitigated by a negative text-indent of a few units to get it to function more like a list-style. 这可能可以通过几个单位的负文本缩进来减轻,以使其更像列表样式。
Another implementation: 另一个实现:
li:before {
content: '\b7\a0';
position:absolute;
right:100%
}
li {
list-style:none;
position:relative;
}
This version seems to work better. 这个版本似乎更好。 I often use :before
and :after
to add extra things like borders, but if you are adding a bullet I imagine that that is not the case. 我经常使用:before
和:after
添加额外的东西,比如边框,但如果你要添加一个子弹,我想是不是这样的。 Even though this is the alternate suggestion, it is probably the preferred one. 虽然这是备用建议,但它可能是首选建议。
list-style-type
doesn't select what character to use, it selects an abstract marker to use. list-style-type
不选择要使用的字符,它选择要使用的抽象标记。 Note the standard states: 注意标准状态:
The value 'none' specifies no marker, otherwise there are three types of marker: glyphs, numbering systems, and alphabetic systems. 值“none”不指定标记,否则标记有三种类型:字形,编号系统和字母系统。
Glyphs are specified with disc, circle, and square. 字形用圆盘,圆形和方形指定。 Their exact rendering depends on the user agent. 它们的精确渲染取决于用户代理。
For more control over the marker, you must either set an image using list-style-image
or use the :before
pseudo element and content
property, setting the list-style-type
to 'none'. 要更好地控制标记,您必须使用list-style-image
设置list-style-image
或使用:before
伪元素和content
属性,将list-style-type
为'none'。 :before
and the content
property aren't supported in IE 7 and earlier, so you must either use list-style-image
to support IE 7 or simply let IE 7 use a different marker. :before
和IE 7及更早版本中不支持content
属性 ,因此您必须使用list-style-image
来支持IE 7,或者只是让IE 7使用不同的标记。 You can use conditional comments to target IE 7 and earlier. 您可以使用条件注释来定位IE 7及更早版本。
You can use an background-image in LI 您可以在LI中使用背景图像
One possible example 一个可能的例子
http://css.maxdesign.com.au/listamatic/vertical05.htm http://css.maxdesign.com.au/listamatic/vertical05.htm
There are a limited number of available options for list-style-type
which are defined in the CSS2 spec . list-style-type
的可用选项数量有限,这些选项在CSS2规范中定义。
You can use: 您可以使用:
If you'd like something custom, use the list-style-image
property 如果您想要自定义内容,请使用list-style-image
属性
If you're styling for browsers that support generated content, you can use: 如果您为支持生成内容的浏览器设计样式,则可以使用:
li:before {
content: '\[utf-8 hex code for character]';
position: absolute;
right: 100%;
}
li {
position: relative;
}
Instead of li:before
, which affects all li's (in menu, tabs, accordion) on page, I have used this: 而不是li:before
,它影响了页面上的所有li(在菜单,标签,手风琴中),我使用了这个:
ul { list-style: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAHCAMAAAAYuxziAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABhQTFRF////cmpmZmZm+MGYqNP/Zmt/06N6j7j/ImXnGgAAABpJREFUeNpiYAABZkZWFgY2JiZ2CAsVAAQYAAPiACwnaqqBAAAAAElFTkSuQmCC'); }
<ul> <li>This is my middot</li> </ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.