【问题标题】:Using chosen.js, how would I add images to the dropdown items?使用 selected.js,如何将图像添加到下拉项?
【发布时间】:2012-09-04 20:59:13
【问题描述】:

使用 selected.js,如何将图像添加到下拉项?

【问题讨论】:

    标签: javascript jquery-chosen


    【解决方案1】:

    通过在选择的列表项上设置background-image

    .chzn-results li {
        background: url('path/to/img.png') no-repeat 3px center;
        padding-left: 12px;
    }
    

    相应地调整像素数。

    【讨论】:

    • 解决方案:CSS 规则应该是background 而不是background-image
    【解决方案2】:

    为了完成 Joseph(我无法对他的回答添加评论),该课程自未知版本以来发生了变化: 这是 v1.0.0 中正确的 css:

    li.active-result {
        background: url('path/to/img.png') no-repeat 3px center;
        text-indent:2em;
    }
    

    谢谢约瑟夫!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      • 2014-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      相关资源
      最近更新 更多