/
How do use a CSS grid to layout a form nicely?

How do use a CSS grid to layout a form nicely?

Say with inputs like a file input and a browse button?

Similar to creating a table but now we include inputs as one of the element types.

<html> <head> <link rel="stylesheet" href="FORM.css"> </head> <body class="FORMpage"> <div class="FORMfileBrowse"> <div class="FORMlabel">Location:</div><input></input><div class="FORMbrowse">Browse</div> <div class="FORMlabel">Location:</div><input></input><div class="FORMbrowse">Browse</div> </div> </body> </html>

and

.FORMpage{ display : grid; grid-auto-rows: 2em; grid-template-columns: 200px 1fr 200px; } .FORMfileBrowse{ grid-row-start: 2; grid-column-start: 2; grid-column-end: 3; display : grid; grid-auto-rows: 2em; grid-template-columns: 100px 1fr 100px; } .FORMlabel{ text-align: right; } .FORMbrowse{ text-align: center; } /* put red debug lines in */ * {outline: 1px red solid; }

We get this:

 

Related content

How do we go about overall page layout with a CSS grid?
How do we go about overall page layout with a CSS grid?
More like this
How can we do a table like display with CSS grid?
How can we do a table like display with CSS grid?
More like this
What is important to do early?
What is important to do early?
Read with this
Other choices for arrangement
Other choices for arrangement
More like this
CSS supports variables
CSS supports variables
Read with this
CSS Positioning - use the grid.
CSS Positioning - use the grid.
More like this