]> git.ardis.lu - ardislu.dev/commitdiff
Set card column width to 320px or screen width, whichever is smaller
authorArdis Lu <ardisglu@gmail.com>
Sun, 28 Mar 2021 04:33:51 +0000 (21:33 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 28 Mar 2021 04:33:51 +0000 (21:33 -0700)
The inner min function prevents column width overflow for devices with a width smaller than 320px

script.js
style.css

index 55a245bf20f438ca4b5e56a67e29d6f039dba10f..dc9fca023704fd5ab5e5e24626af76127bc4f825 100644 (file)
--- a/script.js
+++ b/script.js
@@ -1,5 +1,5 @@
 const main = document.getElementsByTagName("main")[0];
-const initialColumns = Math.max(1, Math.floor(main.clientWidth / 360) - 1);
+const initialColumns = Math.max(1, Math.floor(main.clientWidth / 320) - 1);
 
 /* Generic element builders */
 const createColumnElement = () => {
index 7191b6e87ec287a7f2371d2086fc192cabb794f0..af91a55a8aa3478a3dd14324a1d9ebfbaa0d23ff 100644 (file)
--- a/style.css
+++ b/style.css
@@ -14,7 +14,7 @@ header {
 
 main {
   display: grid;
-  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
+  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
   grid-gap: 1rem;
   justify-items: center;
   margin: 0 auto;
This page took 0.039859 seconds and 4 git commands to generate.