CSS没有文本换行 [英] CSS no text wrap

查看:260
本文介绍了CSS没有文本换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面引用的 http://jsbin.com/eveqe3/edit 代码。

Please see see code http://jsbin.com/eveqe3/edit, also quoted below.

我需要在项目divs中显示文本,这样文本只出现在指定宽度的绿色框中,需要隐藏行的剩余部分。任何建议...

I need to show text inside the item divs in such a way the the text appear only in the green box with specified width rest of the line need to be hidden. Any suggestions please...

<style>
  #container{
    width : 220px;
  }
  .item{
    float:left;
    border: 1px solid #0a0;
    width: 100px;
    height: 12px;
    padding 2px;
    margin: 0px 2px;
  }
  .clearfix{
    clear: both;
  }
</style>
</head>
<body>
  <div id="container">
    <div class="item"> A very loooooooooooooooooooooong text </div>
    <div class="item"> Another looooooooooooooooooooong text </div>
    <div class="clearfix">  </div>
   </div>
</body>
</html>​


推荐答案

to overflow:hidden,use

Additionally to overflow:hidden, use

white-space:nowrap;

这篇关于CSS没有文本换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆