我想知道是否还有其他解决方案:
How to remove the space between inline-block elements?
用于当<span>
标签位于<template is="dom-repeat">
中时删除空格。
例如,假设我们有一个dom-repeat生成表列标题:
<th class="asciitable">
<template is="dom-repeat" items="[[_asciiheader]]">
<span class="asciinumeral">[[item]]</span>
</template>
</th>
我们希望所有元素都看起来像“12345678”,而不是“1 2 3 4 5 6 7 8”。
上面的代码适合“无权访问HTML”的情况,因为
dom-repeat
为我们生成了HTML,因此我们不能将<span>
标记放在同一行上,也不能使用<!--\n-->
技巧。注意,在这种情况下,我们必须将数据绑定(bind)包装在某种<span>
中,因为Polymer 1.0在数据绑定(bind)之前或之后不需要空格。唯一可行的方法就是执行上面的链接所建议的操作:
.asciitable {
padding: 0px;
border-width: 0px;
margin: 0px;
font-size: 0;
}
.asciinumeral, .ascii {
font-size: 16px;
}
但这似乎不理想。
最佳答案
将所有内容写在一行上怎么样?
<template is="dom-repeat" items="[[_asciiheader]]"><span class="asciinumeral">[[item]]</span></template>
这应该为您提供没有空格的数字。