From: Carl Worth Date: Sat, 16 May 2020 20:54:52 +0000 (-0700) Subject: Add styling for some mobile-friendly forms and form fields X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=commitdiff_plain;h=d63fff6b0b7142e9592f627a53d86f457d675ff2 Add styling for some mobile-friendly forms and form fields These fields will reponsively decide whether to layout in 1 or 2 columns depending on whether the fields are declared as "small", "medium", or "large" and the width of the browser's screen. --- diff --git a/style.css b/style.css index 899b902..65b0b17 100644 --- a/style.css +++ b/style.css @@ -18,3 +18,58 @@ h2 { font-size: 110%; font-weight: bold; } + +/*\ +|*| +|*| Responsive form layout +|*| +\*/ + +/* + * + * Within the form, fields can be placed in
elements with + * class "form-field". Each can also have an additional class of one + * of "small", "medium", or "large". These classes will be used to + * select either a 1- or 2-column layout for each row depending on the + * width of the screen. + * + * Expected layout is as follows: + * + * "large" rows: 1-column on all devices + * + * "medium" rows: 2-column on wide displays (laptop/desktop/tablet) + * 1-column on small display (phones) + * + * "small" rows: 2-column on all devices + * + * Finally, a class of either "left" or "right" will select which + * column the field should appear in for fields that end up in 2 + * columns. + */ +form { + max-width: 100%; + display: grid; + grid-template-columns: 49% 49%; + grid-column-gap: 2%; +} + +.form-field.small.left,.form-field.medium.left { + grid-column-start: 1; +} + +.form-field.small.right,.form-field.medium.right { + grid-column-start: 2; +} + +.form-field.large { + grid-column-start: 1; + grid-column-end: span 2; +} + +/* For a narrow screen, use a single-column for medium form fields. */ +@media screen and (max-width: 600px) { + .form-field.medium.left,.form-field.medium.right { + grid-column-start: 1; + grid-column-end: span 2 + } +}