加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 什么是DOM回流?

发布时间:2020-12-14 22:27:09 所属栏目:资源 来源:网络整理
导读:我正在阅读两个css属性之间的区别显示:无和可见性:隐藏并遇到DOM回流术语。 声明是 display: none causes DOM reflow where is visibility: hidden doesn’t. 所以我的问题是: 什么是DOM回流及其工作原理? 解决方法 A reflow computes the layout of the
我正在阅读两个css属性之间的区别显示:无和可见性:隐藏并遇到DOM回流术语。

声明是

display: none causes DOM reflow where is visibility: hidden doesn’t.

所以我的问题是:

什么是DOM回流及其工作原理?

解决方法

A reflow computes the layout of the page. A reflow on an element recomputes the dimensions and position of the element,and it also triggers further reflows on that element’s children,ancestors and elements that appear after it in the DOM. Then it calls a final repaint. Reflowing is very expensive,but unfortunately it can be triggered easily.

Reflow occurs when you:

  • insert,remove or update an element in the DOM
  • modify content on the page,e.g. the text in an input box
  • move a DOM element
  • animate a DOM element
  • take measurements of an element such as offsetHeight or getComputedStyle
  • change a CSS style
  • change the className of an element
  • add or remove a stylesheet
  • resize the window
  • scroll

欲了解更多信息,请参阅:Repaints and Reflows: Manipulating the DOM responsibly

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读