1681 1746 1143 1228 1012 1260 1076 1754 1325 1689 1342 1264 1857 1473 1794 1316 1380 1947 1369 1422 1038 1761 1939 1938 1181 1356 1961 1126 1463 1725 1878 1075 1271 1010 1013 1551 1250 1361 1163 1550 1657 1442 1610 1351 1397 1478 1660 1457 1872 1865 1798 1178 1398 1792 1740 1522 1136 1869 1983 1301 1018 1594 1308 1991 1574 1714 1407 1840 1728 1193 1641 1596 1096 1834 1082 1813 1284 1107 1348 1874 1931 1950 1877 1308 1410 1500 1586 1614 1771 1533 1011 1651 1029 1511 1906 1688 1179 1220 1850 Responsive Layouts, Fewer Media Queries | PHPnews.io

PHPnews.io

Responsive Layouts, Fewer Media Queries

Written by Bram.us / Original link on Nov. 29, 2021

357080.jpg

Over at CSS-Tricks you can read a min-bending article by Temani Afif

Since the introduction of media queries (literally decades ago), CSS has evolved to the points that there are a lot of tricks that can help us drastically reduce the usage of media queries we use. In some cases, I will show you how to replace multiple media queries with only one CSS declaration. These approaches can result in less code, be easier to maintain, and be more tied to the content at hand.

Common theme in all code shown is the use if max() and clamp(), resulting in code that’s hard to grasp:

grid-template-columns: repeat(auto-fit, minmax(clamp(100% / (var(--n) + 1) + 0.1%, (var(--w) - 100vw) * 1000, 100% / (var(--m) + 1) + 0.1%), 1fr));

😵😵

Be sure to stick around for the More Tricks section of the post, as it also holds some nice things you can do:

While I do like the results, I’ll stick to using the more readable CSS Container Queries syntax once that becomes stable 😅

Responsive Layouts, Fewer Media Queries →

bram bram link tutorialzine bram

« Symfony 5.4.0 released - SVGcode: a PWA to convert raster images to SVG vector graphics »