【发布时间】:2019-08-29 13:47:57
【问题描述】:
我将动态项目传递给一个选择>选项,以使列表可以与项目一起选择,并且我想显示该“列表”内联(不带下拉菜单),为此我做了接下来的事情:
这是我的液体代码
<select class="pattern-select single-option-selector single-option-selector-{{ section.id }} product-form__input" id="SingleOptionSelector-{{ section.id }}-{{ forloop.index0 }}" data-index="option{{ forloop.index }}">
{% for value in option.values %}
<option value="{{ value | escape }}"{% if option.selected_value == value %} selected="selected"{% endif %}>{{ value }}</option>
{% endfor %}
</select>
这是我正在使用的 css
.pattern-select {
display: inline-block;
height: 3em;
-webkit-appearance: none;
-moz-appearance: none;
}
.pattern-select option{
display: inline-block;
width: 2.5em;
height: 2.5em;
float:left;
}
我只需要在<select... 中添加size="3" 作为属性以结束该功能,但是当我手动输入时,size="3" 未处理,就好像该属性尚未设置,因此我无法内联显示 select>option 结构。
这是我的 html 输出的样子:
<select class="pattern-select single-option-selector single-option-selector-product-template product-form__input" id="SingleOptionSelector-0" data-index="option1">
<option value="S" selected="selected">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
</select>
有什么建议吗?
干杯!
【问题讨论】:
-
你试过内联css吗?
-
嗨@RodenerDajes,是的,我就是这样写
size="3" -
你能指定你是否使用npm包“液体”,它的版本。以及 node 和 npm 的版本?
-
好吧,我终于找到了一种基本但实用的方法来实现它。谢谢大家
标签: javascript html sass liquid