简体   繁体   English

CSS列表样式图像不在(垂直)中心

[英]css list-style-image is not on (vertical) center

I have this simple ul li script with list-style-image. 我有一个带有列表样式图像的简单ul li脚本。

The problem is that the image is not (vertical) center. 问题在于图像不是(垂直)中心。

vertical-align is not helpful here. 垂直对齐在这里没有帮助。

Any idea ? 任何想法 ?

http://jsfiddle.net/nDX6g/ http://jsfiddle.net/nDX6g/

ul {
    margin-top: 10px;
    padding-left: 50px;
    color: #3C4355;
    margin-bottom: 6px;
}

li {
    margin-left: 20px;
    color: #3C4355;
    line-height: 20px;
    list-style-image: url('http://forum.bizportal.co.il/NewSite/emoticons/smiley9.gif');
}




<ul>
    <li>Text 1</li>
    <li>Text 2</li>
</ul>

Example: http://jsfiddle.net/nDX6g/3/ 示例: http//jsfiddle.net/nDX6g/3/

li {
   list-style: none;
}

li:before {
   content: url(...);
   display: inline-block;
   vertical-align: middle;
   margin-right: .5em;
}

if your items may span on two (or more) lines, then try this other fiddle: http://jsfiddle.net/nDX6g/4/ 如果您的商品可能跨越两行(或更多行),请尝试使用其他小提琴: http : //jsfiddle.net/nDX6g/4/

Screenshot: 截图:

在此处输入图片说明

You can use background image to adjust background position properly: 您可以使用背景图像正确调整背景位置:

li {
    margin-left: 20px;
    color: #3C4355;
    line-height: 20px;
    background: url('http://forum.bizportal.co.il/NewSite/emoticons/smiley9.gif') 0 0 no-repeat;
    padding-left: 20px;
    list-style-type: none;
}

Demo: http://jsfiddle.net/dfsq/nDX6g/2/ 演示: http//jsfiddle.net/dfsq/nDX6g/2/

Check this demo jsFiddle 检查这个演示jsFiddle

CSS CSS

ul {
    margin-top: 10px;
    padding-left: 50px;
    color: #3C4355;
    margin-bottom: 6px;
}

li {
    margin-left: 20px;
    color: #3C4355;
    line-height: 20px;
    padding: 0px 0px 0px 25px;
    list-style: none;
    background: url('http://forum.bizportal.co.il/NewSite/emoticons/smiley9.gif') no-repeat left top;
}

Result 结果

在此处输入图片说明

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

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