javascript - chrome 和 IE 中的 ScrollHeight 值不同
问题描述
如果元素溢出,我想将一个类应用于 div 。为此,我将 ScrollHeight 与 ClientHeight 进行比较。它在 chrome 上运行良好,但在 IE 中不行。下面是代码片段:
componentDidMount() {
this.assign_overflow();
}
assign_overflow = () => {
const element = this.title_ref.current;
element.classList.toggle('overflowing', element.scrollHeight >
element.clientHeight);
};
<div>
<h5 ref={this.title_ref}>header</h5>
</div>
.overflowing::after {
content: "...";
position: absolute;
bottom: -2px;
background-color: yellow;
}
在 IE 中,我看到应用于元素的类“溢出”,即使它不应该是。此外,在 chrome 中,我将 scrollheight 值设为 20,在 IE 中为 22。有人可以帮我解决这个问题。谢谢。
解决方案
推荐阅读
- xcode - Xcode Core Data 彻底崩溃
- object - DOORS 对象删除日期
- python - ModuleNotFoundError:在 AI DevCloud 英特尔中没有名为“keras”的模块
- javascript - 如何存储对象路径
- angularjs - 如何在 html nodejs-->angularjs 中显示响应
- ios - NSUserDefualts 数据在 Preferences 文件夹中重复多次
- android - 改造android中的动态数组解析
- kubernetes - 从 Kubernetes Pod 获取部署注解
- postgresql - 防止影子属性包含在查询中
- android - 使用 Android Studio 获取 Firebase 数据并放入数组