Re:How Math Helped Me Write Less Code and Made Our App Faster
by bbx on Wednesday February 12, 2014 @02:42AM
(#7223084)
Being able to come up with elaborate equations to draw a layout is a smart way to tell the browser how to dynamically resize and position a set of elements. It has, for example, helped me design custom "Pinterest-like" layouts.
Keep in mind though that some simple techniques that require(d) JavaScript can (now) be achieved with CSS only. I'm thinking about how to center vertically and horizontally a fix-sized box, or how to make an element take up the whole height of the viewport (without messing with the scrolling). I myself used to rely upon JavaScript calculations to retrieve dynamically the viewport's height, whereas the browser's rendering engine could actually achieve it way more efficiently and with only a couple of lines of CSS code.
Keep in mind though that some simple techniques that require(d) JavaScript can (now) be achieved with CSS only. I'm thinking about how to center vertically and horizontally a fix-sized box, or how to make an element take up the whole height of the viewport (without messing with the scrolling). I myself used to rely upon JavaScript calculations to retrieve dynamically the viewport's height, whereas the browser's rendering engine could actually achieve it way more efficiently and with only a couple of lines of CSS code.