width - 如何拒绝 "nowrap"以增加元素的宽度?

标签 width ellipsis css nowrap

我有这样的结构:

<table>
<tr>
    <td class = "one">This cell should has width 60%</td>
    <td class = "two">
        <div>
            <div class = "three">Hint</div>
            <div class = "four">
                And ending of this string should be cutted out with ellipsis, no matter how long string will be
            </div>
        </div>
    </td>
</tr>
</table>

使用 CSS

.one { width: 60%; }

.three {
    display: none;
    float: right;
}

.two:hover .three { display: block; }

.four {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

我希望左侧单元格的宽度始终为 60%,右侧单元格占据所有其他空间。当“提示”元素可见和不可见时,右侧单元格中的长单行文本应使用省略号截断。

我尝试过使用display: inlinefloat: leftposition: absolute,但没有得到任何结果不会破坏右侧的 float 提示元素。

jsFiddle 在这里:http://jsfiddle.net/Z2kLV/1/

此外,解决方案不必是跨浏览器的,我只需要它用于 chrome。

请帮忙,我做不到

最佳答案

我的搜索不够好,现在找到了我的答案 here

它是 - 将以下 css 添加到表格元素:

table {
    width: 100%;
    table-layout: fixed;
}

jsFiddle 上的工作示例:http://jsfiddle.net/Z2kLV/5/

关于width - 如何拒绝 "nowrap"以增加元素的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17126721/

相关文章:

html - DIV 宽度 : auto is 0 pixel

javascript - 三.js线宽矛盾

html - 使用 CSS,将 "..."用于溢出的多行 block

html - 将省略号应用于多行文本

jquery - 在一个 div 动画之后仍然落后于其他 div

html - 在 100% 宽度时,我的 div 不包含它们的元素(重叠?)

r - 依赖于 R 中非标准评估的函数的包装器

html - 侧边栏在所有页面上的显示都不一样

html - 如何在 CSS 中创建动态宽度箭头?

css - 当 child 与其自己重叠时停止父 div 的滚动条(溢出)