Showing posts from April, 2018

Adding text fo a file input using CSS Grid

I've been playing with CSS grid, listening to some podcasts and running through a few courses/tutorials.

One of the things that struck me as really useful is the ability to overlay elements on top of each other without using absolute positioning. I seee that this could be particularly useful when you want to have styled content display as part of a file upload process. Using CSS Grid you can have CSS stylable text visible and user selectable text that when clicked on opens a file dialogue.

As you can see in the below CodePen I've simply made a div with a 1:1 grid to act as the container. Into this container I have placed a div with my desired text followed by a input element of type file.
I've then styled these two elements to place them both in the first column of the first row.
This places the second element over the first (the input over the div).
I've then set the opacity on the input to 0 so all the user sees in the div.

See the Pen Text on a file upload using CSS…