html - CSS - 在 li 中显示背景图像

标签 html css bootstrap-4

我正在尝试在自定义的圆形 li 中显示图像。我只想在那个 li 中显示一个成功的刻度图像。我有一个 CSS 作为 -

span.round-tabs {
    width: 50px;
    height: 50px;
    line-height: 50px;
    display: inline-block;
    border-radius: 100px;
    background: white;
    z-index: 2;
    position: absolute;
    left: 0;
    text-align: center;
    font-size: 25px;
}

li.success span.round-tabs.one {
    background-image: url('img/if_Tick_Mark_Dark_1398912.png');
}
 
    
<li class="success">
  <a href="#" aria-controls="home" id="DivPatientDetails" name="PatientDetails" >
      <span class="round-tabs one">
          <i class="icon icon-profile-male"></i>01
          <h4>Patient's Details</h4>
      </span>
  </a>
</li>

但我得到的结果是:

enter image description here

代替:

enter image description here

我在这里错过了什么?

最佳答案

要么使用

background-position: center center;

或使用

background-position-ybackground-position-x 正确定位图像。

然后您可能需要使用 CSS 中的 background-size 规则来确保尺寸正确。如果您发布 jsfiddle,我将很乐意将此解决方案实现到其中供您查看。

关于html - CSS - 在 li 中显示背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46217548/

相关文章:

php - 如果将所需值插入数据库,则永久禁用提交按钮 - php

html - 如何减少时间线面板的分离 Bootstrap

javascript - 避免在单击内部元素时隐藏下拉菜单 [react-bootstrap]

html - 即使不需要,元素也会在 bootstrap 4 导航栏中折叠

html - 如何保证一行中不同的html元素是水平的?

python - 使用 beautifulsoup 提取 html

php - 在wordpress中创建一个包含导航栏的div

javascript - 在 jsfiddle 中旋转 Canvas

javascript - 如何将此鼠标悬停设置为即使鼠标悬停超过 3 秒也能显示?

css - 修复了 react-semantic-ui 中的侧边栏