繁体   English   中英

自定义ul li,将项目符号对准中心(作为文本)?

[英]custom ul li, align bullet to center (as text)?

我正在尝试创建一个custum项目列表(ul li)

我有这个:

ul {
    list-style: none;
    list-style-type: none;  
    padding: 0px;
    margin: 0px;
}

ul li {
    background-image: url(img/bullet.png);
    background-repeat: no-repeat;
    background-position: 0px 5px; 
    padding-left: 10px; 
}

结果文字:

o            some text
o         some other text
o    and again some other text

主文本居中,我也希望项目符号也居中对齐(在文本左侧旁边)。文本对齐无济于事

这个怎么做?

您可以使用:before伪元素使用白色项目符号unicode char( \\25e6 )来呈现项目符号,如下所示:

ul li:before {        
  content:'\25e6';
  margin-right:5px;    
  vertical-align:middle;
  font-size:1.5em;
  line-height:0;
}

演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM