Problem: Custom File Upload Button
Problem description
Given an HTML page containing a label with the class .custom-file that wraps a file input and a span element with the class .button-text displaying “Choose File,’’ write CSS to:
Hide the native file input element.
Style the
.button-textas a button of at least120px × 40pxwith a blue background (#007BFF), white centered text, and4pxborder-radius.Change the
.button-textbackground to a darker blue (#0056B3) onhover.
Goal
Write CSS rules so that clicking the styled .button-text opens the file dialog and the control appears as a custom button with hover feedback.
Constraints
Use only CSS (no JavaScript).
.button-textminimum size should be120pxwidth,40pxheight.Background-colorshould be#007BFF;hoverbackground-colorshould be#0056B3.Text color should be
#FFF, centered both horizontally and vertically.Border-radiusshould be4px.Cursor should be
pointeronhover.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.
Problem: Custom File Upload Button
Problem description
Given an HTML page containing a label with the class .custom-file that wraps a file input and a span element with the class .button-text displaying “Choose File,’’ write CSS to:
Hide the native file input element.
Style the
.button-textas a button of at least120px × 40pxwith a blue background (#007BFF), white centered text, and4pxborder-radius.Change the
.button-textbackground to a darker blue (#0056B3) onhover.
Goal
Write CSS rules so that clicking the styled .button-text opens the file dialog and the control appears as a custom button with hover feedback.
Constraints
Use only CSS (no JavaScript).
.button-textminimum size should be120pxwidth,40pxheight.Background-colorshould be#007BFF;hoverbackground-colorshould be#0056B3.Text color should be
#FFF, centered both horizontally and vertically.Border-radiusshould be4px.Cursor should be
pointeronhover.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.