Custom File Upload Button with HTML & CSS

12/10/2020
Demo
Code
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Custom File Upload Button</title>
<link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
<link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<div class="file-uploader">
<img src="img_cloud.png" alt="img_cloud">
<h2>Custom File Upload</h2>
<input id="file-upload" type="file">
<label for="file-upload">Select Files</label>
</div>
</div>
</body>
</html>
CSS
@charset "utf-8";
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 16px;
}
body {
background-color: #9cffc2;
font-family: futura-pt, sans-serif;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
}
.file-uploader {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
width: 270px;
padding: 20px 10px;
border: 2px solid #3d3935;
border-radius: 4px;
background-color: #fff;
}
.file-uploader img {
width: 40px;
}
.file-uploader h2 {
margin: 10px 0 15px;
color: #3d3935;
font-size: 1.125rem;
letter-spacing: .5px;
}
.file-uploader input[type="file"] {
display: none;
}
.file-uploader label {
padding: 10px 30px;
border-radius: 4px;
background-color: #9cffc2;
color: #3d3935;
font-weight: 500;
font-size: 1.25rem;
letter-spacing: 1px;
cursor: pointer;
}
.file-uploader label:hover {
opacity: .8;
}