Refactoring CSS Locks

In our first Utopia.fyi release, I stumbled upon an elegant way to re-use CSS locks.
In a traditional CSS lock, we have a @media query that locks the selectors when they reach the max viewport size. In this example, we go from 2em to 4em, between viewp…


This content originally appeared on Welcome to my blog on Trys Mudford and was authored by Welcome to my blog on Trys Mudford

In our first Utopia.fyi release, I stumbled upon an elegant way to re-use CSS locks. In a traditional CSS lock, we have a @media query that locks the selectors when they reach the max viewport size. In this example, we go from 2em to 4em, between viewports of 20em and 80em: h2 { font-size: calc(2em + (4 - 2) * ((100vw - 20em) / (80 - 20))); } @media screen and (min-width: 80em) { h2 { font-size: 4em; } } Refactor round one First off, let’s extract the ‘screen’ part of the lock into a CSS custom property.


This content originally appeared on Welcome to my blog on Trys Mudford and was authored by Welcome to my blog on Trys Mudford


Print Share Comment Cite Upload Translate Updates
APA

Welcome to my blog on Trys Mudford | Sciencx (2020-02-06T16:00:00+00:00) Refactoring CSS Locks. Retrieved from https://www.scien.cx/2020/02/06/refactoring-css-locks/

MLA
" » Refactoring CSS Locks." Welcome to my blog on Trys Mudford | Sciencx - Thursday February 6, 2020, https://www.scien.cx/2020/02/06/refactoring-css-locks/
HARVARD
Welcome to my blog on Trys Mudford | Sciencx Thursday February 6, 2020 » Refactoring CSS Locks., viewed ,<https://www.scien.cx/2020/02/06/refactoring-css-locks/>
VANCOUVER
Welcome to my blog on Trys Mudford | Sciencx - » Refactoring CSS Locks. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/02/06/refactoring-css-locks/
CHICAGO
" » Refactoring CSS Locks." Welcome to my blog on Trys Mudford | Sciencx - Accessed . https://www.scien.cx/2020/02/06/refactoring-css-locks/
IEEE
" » Refactoring CSS Locks." Welcome to my blog on Trys Mudford | Sciencx [Online]. Available: https://www.scien.cx/2020/02/06/refactoring-css-locks/. [Accessed: ]
rf:citation
» Refactoring CSS Locks | Welcome to my blog on Trys Mudford | Sciencx | https://www.scien.cx/2020/02/06/refactoring-css-locks/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.