gpt4 book ai didi

javascript - 不同浏览器中文本的大小(宽度)

转载 作者:行者123 更新时间:2023-11-30 06:01:57 25 4
gpt4 key购买 nike

我需要让 div 框中的文本具有精确的宽度。
有没有办法(例如使用 javascript)使所有主流浏览器中的文本看起来大小相同?
例如,如果文本不适合“div”框,则去除一些字母。

最佳答案

只需将以下属性添加到您的 div 的 CSS 规则中:

overflow:hidden; text-overflow:ellipsis; white-space:nowrap;

您可以 see this in action here (JSFiddle) .

关于javascript - 不同浏览器中文本的大小(宽度),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7844703/

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