[Javascript] Layout > Paint > Composite

Layout: 

This step invovles determining the geometry of the page. The browser calculates where each element will be on the screen, considering factors like text size, line height, box size, etc. This process can be triggered by changes to an element's dimensions, position, display, float, overflow, and other properties. Changing the window size can also trigger a layout change.

 

Paint:

This Process is where the browser fills in pixels. It invovles drawing out text, colors, images, borders, and shadows, basically every visual aspect of the elements. Paint is triggered when you change visual properties, such as background color, border color, text color, box shadows, or background images.

 

Composite:

The final process is to layer the painted elements together in the correct order. This is particularly important when elements overlap, or when there are semitransparent elements. Compositing is triggered whenever an element needs to move, or if an element's opacity changes, or if an element is overlaid onto the current page (e.g, a modal or a popup).

 

Answer:

width: Layout > Paint > Composite

opacity: Composite

background-image: Paint > Composite

left: Layout > Paint > Composite

transform: Composite

 

opacity: element will be promoted to a new layer, browser just changes the layer opacity. (Depends on browsers)

.elm {
  opacity: 1;
}

.elm:hover {
  opacity: 0.3;
}

 

transform: element move / animate from one state to another state:

Element will be promoted to a new layer, then move the layer accordingly.

It doesn't really change the layout, because base layer doesn't change. So it just need to be composited

.elm {
  width: 200px;
}

.elm:hover {
  transform: translateX(50px);
}

Note: using translateXor translateYif you want to move the elements, don't use left / right, because `left / right` will cause layout change.

 

posted @   Zhentiw  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2017-06-19 [Node] Catch error for async await
2017-06-19 [Jade] Use Mixins in Pug
2017-06-19 [Node] Define MongoDB Model with Mongoose
2016-06-19 [Webpack 2] Intro to the Production Webpack Course
点击右上角即可分享
微信分享提示