【问题标题】:list-style-image: url('imageurl') does not display the image on webpagelist-style-image: url('imageurl') 不在网页上显示图片
【发布时间】:2020-05-18 13:20:43
【问题描述】:

您好,我正在尝试通过 css 使用客户图像作为列表标记,这是我的代码

<li class="unorderedList">

    Bread 

    <ul>
        <li> brown </li>
        <li> white </li>

    </ul>

</li>

<li> Milk </li>
<li> Butter </li>
<li> Onions </li>
<li> Coriander </li>

图像没有作为我的列表标记加载到网页上,这是我使用的 css。

div.unorderedList { 边框样式:实心; 填充:10px; }

li.unorderedList { list-style-image: url('..\images\marker.png');}

【问题讨论】:

  • 编辑:我确实添加了
      我只是忘了将它添加到顶部的代码中,但它在我的 html 文件 dw 中

    标签: html css list styles


    【解决方案1】:

    我建议不要使用list-style-image 属性。相反,我会使用图像标签。示例:

    .list-image {
      list-style: none;
      padding: 0;
    }
    
    .list-image li img{
      height: 15px;
      width: auto;
      margin-right: 5px;
    }
    <ul class="list-image">
      <li><img src="https://cdn.iconscout.com/icon/free/png-256/right-1478289-1251141.png" alt=""> brown </li>
      <li><img src="https://cdn.iconscout.com/icon/free/png-256/right-1478289-1251141.png" alt=""> white </li>
    </ul>

    但是直接回答你的问题。您没有针对您的列表。 li.unorderedList ul 将是解决方案。

    【讨论】:

    • 谢谢,最后我还是选择了图片标签解决方案,非常感谢。
    • 没问题!如果我的评论解决了您的问题,您介意选择我的评论作为正确答案吗?
    猜你喜欢
    • 1970-01-01
    • 2021-02-21
    • 2021-01-30
    • 2014-05-29
    • 1970-01-01
    • 2012-04-09
    • 2019-02-20
    • 2018-04-10
    • 1970-01-01
    相关资源
    最近更新 更多