如何正确地用CSS包装这个单词?

时间:2013-07-08 04:14:57

标签: html css html5 css3

我有2个单词用下面的包装

  • 文化秃鹰
  • Kleingruppen-Reise旅馆

但是当我使用时:

  

分词:打破所有;

包裹看起来很奇怪。如何将CSS文件调整为精美包装?

这是我的代码:

* {
  margin: 0;
  padding: 0;
}

.tabs-machine {
  margin-top: -12px;
  position: relative;
  height: 89px;
  background: url(http://aquaterra-travel.siampixel.com/images/tabs_machine_bg1.gif) no-repeat center top;
}

.tabs-machine-mask ul {
  width: 600px;
  overflow: hidden;
  margin: 0px auto;
}

.tabs-machine-mask ul li {
  float: left;
  display: inline-block;
  text-align: center;
  margin-left: 1px;
  vertical-align: middle;
}

.tabs-machine-mask ul li a {
  display: table-cell;
  width: 99px;
  height: 76px;
  color: #bf1e2d;
  font-size: 16px;
  font-family: "Myriad Pro", 'Average Sans', sans-serif;
  text-decoration: none;
  vertical-align: middle;
  padding-bottom: 1em;
  white-space: -moz-pre-wrap !important;
  /* Mozilla, since 1999 */
  white-space: -pre-wrap;
  /* Opera 4-6 */
  white-space: -o-pre-wrap;
  /* Opera 7 */
  white-space: pre-wrap;
  /* css-3 */
  word-wrap: break-word;
  /* Internet Explorer 5.5+ */
  word-break: break-all;
  white-space: normal;
}
<div class="tabs-machine">
  <div class="tabs-machine-mask">
    <ul>
      <li><a href="#">Culture Vulture</a></li>
      <li><a href="#">Kleingruppen-Reise</a></li>
      <li><a href="#">Explorer</a></li>
      <li><a href="#">Family</a></li>
      <li><a href="#">Festival and Events</a></li>
      <li><a href="#">Marine</a></li>
    </ul>
  </div>
  <div></div>
</div>

Sample

1 个答案:

答案 0 :(得分:1)

我相信你正在寻求防止单词破坏/连接中​​间词。

尝试删除word-break:break-all;上的.tabs-machine-mask ul li a

.tabs-machine-mask ul {
  width: 600px;
  overflow: hidden;
  margin: 0px auto;
}

.tabs-machine-mask ul li {
  float: left;
  display: inline-block;
  text-align: center;
  margin-left: 1px;
  vertical-align: middle;
}

.tabs-machine-mask ul li a {
  display: table-cell;
  width: 99px;
  height: 76px;
  color: #bf1e2d;
  font-size: 16px;
  font-family: "Myriad Pro", 'Average Sans', sans-serif;
  text-decoration: none;
  vertical-align: middle;
  padding-bottom: 1em;

  white-space: -moz-pre-wrap !important;
  white-space: -pre-wrap;
  white-space: -o-pre-wrap;
  white-space: pre-wrap;
  word-wrap: break-word;
   /* word-break: break-all; */
  white-space: normal;
}
<div class="tabs-machine">
  <div class="tabs-machine-mask">
    <ul>
      <li><a href="#">Culture Vulture</a></li>
      <li><a href="#">Kleingruppen-Reise</a></li>
      <li><a href="#">Explorer</a></li>
      <li><a href="#">Family</a></li>
      <li><a href="#">Festival and Events</a></li>
      <li><a href="#">Marine</a></li>
    </ul>
  </div>
  <div></div>
</div>