首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何防止标签自动换行?

如何防止标签自动换行?
EN

Stack Overflow用户
提问于 2018-07-29 08:47:20
回答 1查看 107关注 0票数 1

我有一大堆不想换行的标签,但是我do想让标签列表换行。例如:

代码语言:javascript
复制
[first] [second thing] [yet another thing]

我不想要的是:

代码语言:javascript
复制
[first] [second 
thing] [yet another thing]

我在标签中破坏了

我想要的是这样的:

代码语言:javascript
复制
[first] [second thing] 
[yet another thing]

我搞砸了

代码语言:javascript
复制
word-break: break-word;
/* white-space: nowrap; */

在父级和子级上,但没有任何成功。要么整个字段只以一行结束-根本没有换行,要么我在标签中换行。

目前,我有以下内容:

代码语言:javascript
复制
.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; */
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-29 09:14:18

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

CSS代码:

代码语言:javascript
复制
.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:

代码语言:javascript
复制
<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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51576355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档