1

我有很多我不想自动换行的标签,但我确实想让标签列表换行。例如:

[first] [second thing] [yet another thing]

我不想要的是:

[first] [second 
thing] [yet another thing]

即在标签中断。

我想要的是这样的:

[first] [second thing] 
[yet another thing]

我已经搞砸了

word-break: break-word;
/* white-space: nowrap; */

对父母和孩子,没有任何成功。要么整个​​字段结束为一行 - 根本没有中断,要么我在标签内得到中断。

目前我有这个:

.tag-box {
  word-break: break-word;
}

.tag {
  color: white;
  background: #000;
  border: 1px solid white;
  border-radius: 5px;
  margin-bottom: 10px;
  margin-right: 5px;  
  padding: 5px;
  line-height: 200%;
  /* word-break: break-word; */
  /* white-space: nowrap; */
}
4

1 回答 1

1

这是一个小提琴:http: //jsfiddle.net/5fev6o2p/6/

CSS 代码:

.tag-box {
  word-break: break-word;
}

.tag {
  color: white;
  background: #000;
  border: 1px solid white;
  border-radius: 5px;
  margin-bottom: 10px;
  margin-right: 5px;  
  padding: 5px;
  line-height: 200%;
  display:inline-block;
}

HTML:

<ul class="tag-box">
  <li class="tag">[first]</li>
  <li class="tag">[second thing]</li>
  <li class="tag">[third thing]</li>
  <li class="tag">[yet another thing]</li>
  <li class="tag">[first]</li>
  <li class="tag">[second thing]</li>
  <li class="tag">[third thing]</li>
  <li class="tag">[yet another thing]</li>
</ul>
于 2018-07-29T01:14:18.333 回答