I want to create multilevel select2 options with indentation but I don't want to use optgroup
elements for this because I want to allow select also main categories. Is there any way to style if for select2?
My raw HTML select looks like this:
<select class="js-select-multiple">
<option class="l1">Option 1</option>
<option class="l2">Suboption 1</option>
<option class="l2">Suboption 2</option>
<option class="l2">Suboption 3</option>
<option class="l1">Option 2</option>
...
</select>
<script>$(".js-select-multiple").select2({maximumSelectionLength: 5});</script>
So without using Select2 I can add text-indent
property to .l2
class. However it seems that Select2
doesn't use those classes that are used for option, so styling those classes won't work.
Is there any workaround for that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…