当前位置: 首页 > 图文教程 > 网页制作 > CSS样式表 > 网页制作学习:reflow概念

CSS样式表
字符不会撑大表格的常见css样式
表格高级使用技巧_把表格进行到底(必看)
网页中Span和Div的区别
在IE与FF中如何居中的css写法
javascript横排竖排标准选项卡效果代码
解决ie动态修改link样式,import css不刷新的问题
css不用图片美化按钮
网页打开新窗口target=_blank不符合标准
Javascript的匿名函数讲解
Firefox2中输入框丢失光标bug的解决方法
Firefox返回时Iframe的显示Bug的解决方法
使网页成黑白色调的滤镜
CSS学习笔记Padding 属性中参数的定义与使用
无限级CSS树形菜单 Ver2.0
css多行多列的新闻模式
Internet Explorer 8 beta 中文版与IE7共存的解决方法
CSS对Web页面载入效率的影响分析总结
巧妙地使用CSS选择器
去除链接元素的虚线框 兼容IE7、IE6、FF
DIV border边框显示不完全问题的解决方法

CSS样式表 中的 网页制作学习:reflow概念


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 95 ::
收藏到网摘: n/a

如果对于 reflow 这个概念你还不太清楚或者不知道,请先阅读:

Yahoo! 性能工程师 Nicole Sullivan 在最新的文章 《Reflows & Repaints: CSS Performance making your JavaScript slow?》 中总结了导致 reflow 发生的一些因素:

  1. 调整窗口大小(Resizing the window)
  2. 改变字体(Changing the font)
  3. 增加或者移除样式表(Adding or removing a stylesheet)
  4. 内容变化,比如用户在input框中输入文字(Content changes, such as a user typing text in
    an input box)
  5. 激活 CSS 伪类,比如 :hover (IE 中为兄弟结点伪类的激活)(Activation of CSS pseudo classes such as :hover (in IE the activation of the pseudo class of a sibling))
  6. 操作 class 属性(Manipulating the class attribute)
  7. 脚本操作 DOM(A script manipulating the DOM)
  8. 计算 offsetWidth 和 offsetHeight 属性(Calculating offsetWidth and offsetHeight)
  9. 设置 style 属性的值 (Setting a property of the style attribute)

reflow 会引起开销,影响页面的性能,那如何才能做到合理的优化呢?Nicole Sullivan 也提供了部分建议:

  1. 如果想设定元素的样式,通过改变元素的 class 名 (尽可能在 DOM 树的最里层)(Change classes on the element you wish to style (as low in the dom tree as possible))
  2. 避免设置多项内联样式(Avoid setting multiple inline styles)
  3. 应用元素的动画,使用 position 属性的 fixed 值或 absolute 值(Apply animations to elements that are position fixed or absolute)
  4. 权衡平滑和速度(Trade smoothness for speed)
  5. 避免使用 table 布局(Avoid tables for layout)
  6. 避免使用CSS的 JavaScript 表达式 (仅 IE 浏览器)(Avoid JavaScript expressions in the CSS (IE only))

详细阅读:

原文:http://www.planabc.net/2009/04/13/reflow/