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! While you're at it, check out some resources Treehouse students have shared here.
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 trialBrad Lacke
7,438 PointsUsing 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
vryiziilos
Full Stack JavaScript Techdegree Student 23,052 PointsHere'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.
John Tasto
21,587 PointsI 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.
Brad Lacke
7,438 PointsBrad Lacke
7,438 PointsThank you for this! Exactly what I needed to understand.
vryiziilos
Full Stack JavaScript Techdegree Student 23,052 Pointsvryiziilos
Full Stack JavaScript Techdegree Student 23,052 PointsYou are welcome!