css - 文本溢出省略号不起作用?

标签 css

JSFIDDLE:

http://jsfiddle.net/vxghC/4/

HTML:

<div class="study-box folder-box">
    <div class="folder-box-title">
        <div> TEST TEST TEST TEST TEST </div>
    </div>
</div>

JS:

.folder-box-title > div {
margin-left: 10px;
margin-bottom: 7px;
-ms-text-overflow: ellipsis !important;
-o-text-overflow: ellipsis !important;
text-overflow: ellipsis !important;
white-space:nowrap;
}
.study-box {
    width: 200px;
    height: 120px;
    margin: 2px;
    color: white;
    background-color: blue;
    text-align: center;
    font-size: 15px;
}

我做错了什么?

最佳答案

尝试将overflow:hiddenoverflow:auto 添加到您的.folder-box-title,如下所示:http://jsfiddle.net/cWDtM/

更多信息:http://quirksmode.org/css/user-interface/textoverflow.html

text-overflow comes into play only when:

  1. the box has overflow other than visible (with overflow: visible the text simply flows out of the box)
  2. the box has white-space: nowrap or a similar method of constraining the way the text is laid out. (Without this, the text would wrap to the next line)

关于css - 文本溢出省略号不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17660736/

相关文章:

html - 在当前选择的菜单项旁边对齐元素

html - 我可以将 &lt;style&gt;...&lt;/style&gt; 标签放在 HTML 文件的正文中以通过电子邮件发送吗?

css - 蓝图CSS的填充问题

css:使固定位置的 div 中的内容可滚动

html - 对齐元素 : center distorts height of parent

jquery - 动画到顶部

jquery - 使用 text-align : center 更改内容时防止文本突然移动

MouseOver 上的 JavaScript 改变 BODY 样式。在 MouseOut 上反转

html - <legend> 标签接受内联宽度

overflow - 变换比例和高度 100%