Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS - Beyond the Basics Understanding CSS Transitions and Transforms Transforms: translate()

Brad Lacke
Brad Lacke
7,438 Points

Using translate() vs. positioning offsets (?)

When Guil in this video says to consider using translate() instead of relative or absolute positioning offsets, as translate uses the GPU and can result in cleaner, faster results, does he mean:

a.) use translate instead of positioning offsets when, say, you want an element to have two different locations and a transition on hover, like in this video?

Or does he mean

b) actually use translate instead of offsets for static positioning of elements in layout?

The latter is kind of exciting, but I can also see how it makes things a little tricky. Would love to hear some thoughts.

2 Answers

Here's another benefit for using translate: When using translate instead of positioning, you don't have to worry about breaking page flow. You won't have to mess with margins and paddings regardless of elements initial positioning (static, relative).

Also browser support looks pretty good (except IE8), just remember that transitions are supposed to enhance user experience while content stays the same. Older browsers will still render all elements properly, but simply ignore fancy animations so no harm done.

Brad Lacke
Brad Lacke
7,438 Points

Thank you for this! Exactly what I needed to understand.

You are welcome!

I would think you'd still want to statically position your elements using traditional methods. For static positioning, there is not much point in using GPU acceleration because framerate is not a consideration. Traditional positioning methods also have broader support in older browsers.