请参阅下面的代码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)
Mac*_*ade 21
只需使用:
overflow: hidden;
white-space: nowrap;
Run Code Online (Sandbox Code Playgroud)
在你的项目的div中