Skip to content

Commit

Permalink
Re-structure sentence in translate vs abs. pos. (yangshun#86)
Browse files Browse the repository at this point in the history
- Re-structured a sentence
- Changed "takes up" to "occupies" to be more concise
  • Loading branch information
jblang94 authored and yangshun committed Mar 7, 2018
1 parent 21e6df7 commit 19bc403
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions questions/css-questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ Another method would be to use JavaScript to replace the `<img>` `src` attribute

### Is there any reason you'd want to use `translate()` instead of `absolute` positioning, or vice-versa? And why?

`translate()` is a value of CSS `transform`. Changing `transform` or `opacity` does not trigger browser reflow or repaint, only compositions, whereas changing the absolute positioning triggers `reflow`. `transform` causes the browser to create a GPU layer for the element but changing absolute positioning properties uses the CPU. Hence `translate()` is more efficient and will result in shorter paint times for smoother animations.
`translate()` is a value of CSS `transform`. Changing `transform` or `opacity` does not trigger browser reflow or repaint but does trigger compositions; whereas changing the absolute positioning triggers `reflow`. `transform` causes the browser to create a GPU layer for the element but changing absolute positioning properties uses the CPU. Hence `translate()` is more efficient and will result in shorter paint times for smoother animations.

When using `translate()`, the element still takes up its original space (sort of like `position: relative`), unlike in changing the absolute positioning.
When using `translate()`, the element still occupies its original space (sort of like `position: relative`), unlike in changing the absolute positioning.

###### References

Expand Down

0 comments on commit 19bc403

Please sign in to comment.