Using chosen.js, how would I add images to the dropdown items?
By setting a background-image
on chosen's list items:
.chzn-results li {
background: url('path/to/img.png') no-repeat 3px center;
padding-left: 12px;
}
Adjust the pixel count accordingly.
To complete Joseph (I can't add comment to his answer), the class has changed since an unknown version: Here's the correct css in v1.0.0:
li.active-result {
background: url('path/to/img.png') no-repeat 3px center;
text-indent:2em;
}
Thx Joseph!
来源:https://stackoverflow.com/questions/12271283/using-chosen-js-how-would-i-add-images-to-the-dropdown-items