gpt4 book ai didi

html - 如何处理文本溢出。是否有与 IE 和 Safari 的文本溢出样式等效的 Firefox?

转载 作者:太空宇宙 更新时间:2023-11-04 16:12:01 25 4
gpt4 key购买 nike

当文本溢出并且对于容器而言太大时,我想向用户提供某种指示。

我正在使用 overflow:hidden 所以,有些文本有可能不可见,我想找到一种方法让用户知道何时/如果发生这种情况。

文本溢出样式适用于此,但 FireFox 不支持它。

更新:此链接归功于@Galled:text-overflow:ellipsis in Firefox 4? (and FF5)它展示了如何在旧版本的 FireFox 中模拟 text-overflow:ellipsis。

看起来 text-overflow:ellipsis 在更新版本的 FireFox 中工作,如下所述:https://developer.mozilla.org/en/CSS/text-overflow#Browser_compatibility

更新:我真的很喜欢这个 JavaScript 解决方案 ( Determine if an HTML element's content overflows )。当然,尽管我一直在寻找纯 HTML/CSS 解决方案,但使用 JavaScript 可以让您更好地控制溢出内容的显示方式。

最佳答案

根据 this , Firefox 支持文本溢出(但在 7.0 版中)。

我做了一个简单的测试,在 Firefox 6.0 下工作有缺陷:

<html>
<head>
<style>
p {
white-space: nowrap;
width: 100%;
overflow: hidden; /* "overflow" value must be different from "visible" */

text-overflow: ellipsis;
}

div{
width:30px;
}
</style>
</head>
<body >
<div>
<p>Hello, hello, hello, hello, hello, hello, hello, hello, hello, hello</p>
</div>
</body>
</html>

关于html - 如何处理文本溢出。是否有与 IE 和 Safari 的文本溢出样式等效的 Firefox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8229667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com