{"id":244736,"date":"2016-08-19T05:26:44","date_gmt":"2016-08-19T12:26:44","guid":{"rendered":"http:\/\/css-tricks.com\/?p=244736"},"modified":"2016-08-19T05:26:44","modified_gmt":"2016-08-19T12:26:44","slug":"css-locks","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/css-locks\/","title":{"rendered":"CSS “locks”"},"content":{"rendered":"

Tim Brown with a new (metaphorical) term to describe a value that can fluctuate between two set values:<\/p>\n

In canal and river navigation, a lock is a device used for raising and lowering vessels between stretches of water that are at different levels. That\u2019s exactly what our formula accomplishes. Our formula is a CSS calc \u201clock\u201d.<\/p><\/blockquote>\n

To fluctuate<\/a> between a 1.3em and 1.5em line-height depending on the screen width:<\/p>\n

line-height: calc(1.3em + (1.5 - 1.3) * ((100vw - 21em)\/(35 - 21)));<\/code><\/pre>\n

Bram Stein made a helper plugin for PostCSS<\/a>. <\/p>\n

Part of the “lock” is an additional media query that overrides the value at one end of the extremes. Similar to what Mike Riethmuller did<\/a> when he was playing with molten leading and how Eduardo Bou\u00e7as approached viewport sized type<\/a> with minimums and maximums. <\/p>\n","protected":false},"excerpt":{"rendered":"

Tim Brown with a new (metaphorical) term to describe a value that can fluctuate between two set values: In canal and river navigation, a lock is a device used for raising and lowering vessels between stretches of water that are at different levels. That\u2019s exactly what our formula accomplishes. Our formula is a CSS calc […]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[17],"tags":[],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":194152,"url":"https:\/\/css-tricks.com\/fun-line-height\/","url_meta":{"origin":244736,"position":0},"title":"Fun with line-height!","date":"January 26, 2015","format":false,"excerpt":"The line-height property in CSS controls the space between lines of text. It is often set in a unitless value (e.g. line-height: 1.4;) so that it is proportional to the font-size. It's a vital property for typographic control. Too low and lines are awkwardly squished together; too high and lines\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":303923,"url":"https:\/\/css-tricks.com\/a-complete-guide-to-calc-in-css\/","url_meta":{"origin":244736,"position":1},"title":"A Complete Guide to calc() in CSS","date":"March 17, 2020","format":false,"excerpt":"CSS has a special calc() function for doing basic math. In this guide, let's cover just about everything there is to know about this very useful function. Here's an example: .main-content { \/* Subtract 80px from 100vh *\/ height: calc(100vh - 80px); } In this guide, let's cover just about\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/03\/calc-guide.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":341584,"url":"https:\/\/css-tricks.com\/hexagons-and-beyond-flexible-responsive-grid-patterns-sans-media-queries\/","url_meta":{"origin":244736,"position":2},"title":"Hexagons and Beyond: Flexible, Responsive Grid Patterns, Sans Media Queries","date":"June 3, 2021","format":false,"excerpt":"A little while back, Chris shared this nice hexagonal grid. And true to its name, it\u2019s using\u2009\u2014wait for it\u2009\u2014\u2009CSS Grid to form that layout. It\u2019s a neat trick! Combining grid columns, grid gaps, and creative clipping churns out the final result. A similar thing could be accomplished with flexbox, too.\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/05\/featured-image.png?fit=1200%2C524&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":365738,"url":"https:\/\/css-tricks.com\/cool-hover-effects-that-use-css-text-shadow\/","url_meta":{"origin":244736,"position":3},"title":"Cool Hover Effects That Use CSS Text Shadow","date":"May 13, 2022","format":false,"excerpt":"In my last article we saw how CSS background properties allow us to create cool hover effects. This time, we will focus on the CSS text-shadow property to explore even more interesting hovers. You are probably wondering how adding shadow to text can possibly give us a cool effect, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2022\/05\/text-shadow.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":344147,"url":"https:\/\/css-tricks.com\/of-course-we-can-make-a-css-only-clock-that-tells-the-current-time\/","url_meta":{"origin":244736,"position":4},"title":"Of Course We Can Make a CSS-Only Clock That Tells the Current Time!","date":"July 16, 2021","format":false,"excerpt":"Let\u2019s build a fully functioning and settable \u201canalog\u201d clock with CSS custom properties and the calc() function. Then we\u2019ll convert it into a \u201cdigital\u201d clock as well. All this with no JavaScript! Here\u2019s a quick look at the clocks we\u2019ll make: https:\/\/www.youtube.com\/watch?v=Wzi2ogTMhqE& GitHub repo Brushing up on the calc() function\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/1fpsekfFXE-vE42JrzL_uuA.jpeg?fit=1000%2C400&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":374466,"url":"https:\/\/css-tricks.com\/manuel-matuzovic-max-trickery\/","url_meta":{"origin":244736,"position":5},"title":"Manuel Matuzovic: max() Trickery","date":"October 18, 2022","format":false,"excerpt":"By way of a post by Manuel Matuzovi\u0107 which is by way of a demo by Temani Afif. .wrapper { margin-inline: max(0px, ((100% - 64rem) \/ 2)); } You'd be doing yourself a favor to read Manuel's breakdown of all what's happening here, but it basically works out to the\u2026","rel":"","context":"In "Link"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/08\/full-width-inner-content.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":null,"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/244736"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=244736"}],"version-history":[{"count":1,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/244736\/revisions"}],"predecessor-version":[{"id":244740,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/244736\/revisions\/244740"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=244736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=244736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=244736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}