html - 图片未垂直居中

标签 html css

为什么图像不在 li 的中心?它的尺寸是 25x25px。

#information-list li {
    height: 50px;
    line-height: 50px;
    padding: 0 10px;
    border-bottom: 1px solid #c1c0bf;
}

#information-list li img {
    vertical-align: middle;
    margin-right: 10px;
}
<ul id="information-list" class="flat-list">
    <li>
        <img src="images/test.png" />
        <strong>Foo</strong>
    </li>
    ...

enter image description here

最佳答案

试试这个:

#information-list li {
    height: 50px;
    line-height: 50px;
    padding: 0 10px 0 20px;
    border-bottom: 1px solid #c1c0bf;
    background:transparent url(images/test.png) no-repeat left center;
}
<ul id="information-list" class="flat-list">
    <li>
        <strong>Foo</strong>
    </li>
    ...

关于html - 图片未垂直居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9615053/

相关文章:

css - 合并两个相邻 sibling 的CSS

html - <thead> 和 <th> 与表格的宽度不匹配

html - 换行时引入元素宽度?

html - Bootstrap CSS 面板标题调整

javascript - 用JS改变输入框的值

javascript - 将同一小部件​​的多个实例插入到页面中

javascript - 允许 div 仅垂直增长 x 个像素然后显示滚动条?

javascript - 当我单击提交按钮并在当前事件选项卡中触发图像

javascript - 在没有任何 PHP 的情况下刷新 HTML 中的 div?

html - 重叠粘性标题的问题(重叠其下方的主要内容)