Ilj*_*lja 10 html css list css3
所以我有
<ul>
<li>Hello</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
和
li {
list-style-image: url(../img/bullet.png); /* 13x13 px */
/* line-height: 13px; */
/* vertical-align: middle; */
padding-left: 5px;
}
Run Code Online (Sandbox Code Playgroud)
看起来像
正如你可以看到文本和图像元素<li>
没有垂直对齐(图像高于文本),我尝试应用行高和垂直对齐(注释掉代码),但它甚至没有.有没有办法实现良好的一致性?
Ten*_*eff 18
在您的情况下,填充将仅影响元素内部的任何内容 - 文本.
唯一可用的位置调整属性是list-style-position,但唯一允许的值是inherit
,inside
或outside
.最常见的做法是使用:
list-style: none;
Run Code Online (Sandbox Code Playgroud)
然后应用所需的图像作为<li>
背景
li {
/** the image will be vertically aligned in the center **/
background: url(../img/bullet.png) left center no-repeat;
/** move the text to the right **/
padding-left: 20px;
}
Run Code Online (Sandbox Code Playgroud)