CSS没有文字换行

Mit*_*ran 56 html css text

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

我需要以这样的方式在项目div中显示文本,文本只出现在具有指定宽度的绿色框中,需要隐藏该行的其余部分.有什么建议请...

<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>?
Run Code Online (Sandbox Code Playgroud)

xor*_*_eq 158

溢出:隐藏,使用

white-space:nowrap;
Run Code Online (Sandbox Code Playgroud)

  • 是啊!,这就是我想要的! (2认同)

Mac*_*ade 21

只需使用:

overflow: hidden;
white-space: nowrap;
Run Code Online (Sandbox Code Playgroud)

在你的项目的div中