首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS:连字符音节(如果不可能的话)

CSS:连字符音节(如果不可能的话)
EN

Stack Overflow用户
提问于 2017-06-02 08:41:16
回答 2查看 1.9K关注 0票数 1

我想破解我的短信。实际上,我使用的是word-break: break-all;,这看起来不太好。

我想试着在空间之后剪短,只有在没有可能的情况下,在任何字母之后都要剪掉。

代码语言:javascript
复制
<div class="name td" style="word-break: all;">
TestTestTestTestTestTestTestTestTestTestTestTestTe stTestTestTestTestTestTestTestTestTestTestTestTestTestTest
</div>

display: table-cell;
border: thin solid black;
padding: 5px;
height: 100%;
vertical-align: middle;
word-break: break-all;

如果可能的话,我想在太空后休息,其他的在任何信件之后。有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-06-02 10:20:54

word-wrap: break-word;将为您解决这一问题,但不会使用现有的标记与display: table-cell相结合,因为table-cell会随着内容的增长而增长。

因此,要使您的案例正常工作,您需要在table-layout: fixed; width: 100%;上设置table,并添加一个div包装器,其中包含word-wrap: break-word;

代码语言:javascript
复制
.table {
  display: table;
  table-layout: fixed;
  width: 100%;
}
.td {
  display: table-cell;
  border: thin solid black;
  padding: 5px;
  height: 100%;
  vertical-align: middle;
}
.td .wrapword {
  word-wrap: break-word;
}
代码语言:javascript
复制
<div class="table">
  <div class="name td">
    <div class="wrapword">
      TestTestTestTestTestTestTestTestTestTestTestTestTe stTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest
    </div>
  </div>
</div>

根据评论更新

如果水平增长良好,那么word-wrap: break-word;就足够了。

代码语言:javascript
复制
.td {
  display: table-cell;
  border: thin solid black;
  padding: 5px;
  height: 100%;
  vertical-align: middle;
  word-wrap: break-word;
}
代码语言:javascript
复制
<div class="table">
  <div class="name td">
      TestTestTestTestTestTestTestTestTestTestTestTestTe stTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest
  </div>
</div>

票数 1
EN

Stack Overflow用户

发布于 2017-06-02 09:53:24

尝试word-wrap:break-word,,当它达到外部包装宽度的末尾时,它就会中断。

代码语言:javascript
复制
<div class="name td" style="word-wrap: break-word;">
    TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest
</div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44324473

复制
相关文章

相似问题

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