重复使用' <span> '空格解决方案

dom-repeat with `<span>` whitespace solution

本文关键字:空格 解决方案 span      更新时间:2023-09-26

我想知道是否有一个解决方案,而不是这里:

如何移除行内块元素之间的空格?

用于删除<span>标记在<template is="dom-repeat">中的空白。

。,假设我们有一个dom-repeat生成一个表列标头:

    <th class="asciitable">
      <template is="dom-repeat" items="[[_asciiheader]]">
        <span class="asciinumeral">[[item]]</span>
      </template>
    </th>

我们希望所有的元素都显示为"12345678",而不是"12345678"。

以上符合"不能访问HTML"的情况,因为dom-repeat为我们生成HTML,因此我们不能将<span>标记放在同一行,或者使用<!--'n-->技巧。请注意,我们必须将数据绑定包装在某个东西中,在本例中是<span>,因为Polymer 1.0在数据绑定之前或之后不需要空格。

唯一可行的方法就是按照上面的链接做:

.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>