【问题标题】:Simple List Items With Check marks带有复选标记的简单列表项
【发布时间】:2016-11-14 17:35:01
【问题描述】:

我正在尝试构建一个在列表项旁边有复选标记的列表。因此,将文本装饰替换为对勾的 png 图像。目前我无法显示复选标记图像。这是代码:

<ul class="masterList">
  <li>Quickly organize small items and prep for dusting</li>
  <li>Quickly organize small items and prep for dusting</li>
  <li>Quickly organize small items and prep for dusting</li>
</ul>

.masterlist li::before
{
  background-image: url("https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-128.png");
    content: "";
    display: block;
    height: 31px;
    left: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
}

codepen 链接:http://codepen.io/anon/pen/KNMgea

【问题讨论】:

  • 你的css有错别字,masterlist中的L没有大写,但在html中
  • 请注意,它仍然没有输出

标签: list listitem unordered


【解决方案1】:

从这个开始,然后添加你的其他属性:

HTML

<ul>
  <li>Quickly organize small items and prep for dusting</li>
  <li>Quickly organize small items and prep for dusting</li>
  <li>Quickly organize small items and prep for dusting</li>
</ul>

CSS

ul
{
  list-style-image: url('http://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-128.png');
}

【讨论】:

  • 如果你这样做,你就无法控制图标的位置
  • 将它逐个添加回来,因为问题在于您引用图像的方式
  • 这是一个使用背景图像的示例:tidyhouse.ca
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-02
  • 1970-01-01
  • 2023-03-25
相关资源
最近更新 更多