CSS Contextual Spacing

In Contextual Spacing For Intrinsic Web Design Stephanie Eckles talks about properties and functions for intrinsic design, which allow you to do some really nice things. You can get rid of using some of your media queries. There are quite a few example…


This content originally appeared on foobartel.com :: Stream and was authored by foobartel.com :: Stream

In Contextual Spacing For Intrinsic Web Design Stephanie Eckles talks about properties and functions for intrinsic design, which allow you to do some really nice things. You can get rid of using some of your media queries. There are quite a few examples of new properties and functions that, when used properly, will make your code a little prettier, a little more modern and a little more fun, because new ;) One of my favorite examples in this article is the following code, which basically can serve as your new version for a centered container (wrapper) class, spacing included:

.container {
  width: min(100vw - 3rem, 80ch);
  margin-inline: auto;
}

Below you can find the slightly more advanced rule which uses a CSS custom property with the 80ch value from above as the fallback, in case custom properties are not supported. Pretty neat.

.container {
  width: min(100vw - 3rem, var(--container-max, 80ch) );
  margin-inline: auto;
}

So far I haven't worked much with clamp() and friends yet, but this definitely is something to pack into the toolbox for 2022. I usually don't mind writing media queries, but I’m always game to reduce some of the code required, even if only for convenience. Worth a look at.


This content originally appeared on foobartel.com :: Stream and was authored by foobartel.com :: Stream


Print Share Comment Cite Upload Translate Updates
APA

foobartel.com :: Stream | Sciencx (2022-05-18T22:00:00+00:00) CSS Contextual Spacing. Retrieved from https://www.scien.cx/2022/05/18/css-contextual-spacing/

MLA
" » CSS Contextual Spacing." foobartel.com :: Stream | Sciencx - Wednesday May 18, 2022, https://www.scien.cx/2022/05/18/css-contextual-spacing/
HARVARD
foobartel.com :: Stream | Sciencx Wednesday May 18, 2022 » CSS Contextual Spacing., viewed ,<https://www.scien.cx/2022/05/18/css-contextual-spacing/>
VANCOUVER
foobartel.com :: Stream | Sciencx - » CSS Contextual Spacing. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/05/18/css-contextual-spacing/
CHICAGO
" » CSS Contextual Spacing." foobartel.com :: Stream | Sciencx - Accessed . https://www.scien.cx/2022/05/18/css-contextual-spacing/
IEEE
" » CSS Contextual Spacing." foobartel.com :: Stream | Sciencx [Online]. Available: https://www.scien.cx/2022/05/18/css-contextual-spacing/. [Accessed: ]
rf:citation
» CSS Contextual Spacing | foobartel.com :: Stream | Sciencx | https://www.scien.cx/2022/05/18/css-contextual-spacing/ |

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.