--- category: Input created: '2019-11-29' description: Create an upload button with CSS flexbox keywords: css file input, css flexbox, css upload button thumbnail: /assets/css-layout/thumbnails/upload-button.png title: Upload button --- ## HTML ```html index.html
...
...
``` ## CSS ```css styles.css .upload-button { /* Used to position the input */ position: relative; /* Center the content */ align-items: center; display: flex; /* Border */ border: 1px solid #d1d5db; border-radius: 0.25rem; padding: 0.25rem 0.5rem; } .upload-button__input { /* Take the full size */ height: 100%; left: 0; position: absolute; top: 0; width: 100%; /* Make it transparent */ opacity: 0; } .upload-button__icon { margin-right: 0.5rem; } ``` ```css placeholders.css hidden .lines { padding: 0.25rem 0; width: 100%; align-items: center; display: flex; justify-content: center; flex-direction: column; } .line { background: #d1d5db; height: 1px; margin-bottom: 0.25rem; } .line.line--20 { width: 20%; } .line.line--40 { width: 40%; } .line.line--60 { width: 60%; } .line.line--80 { width: 80%; } .line.line--100 { width: 100%; } ``` ```css styles.css hidden body { align-items: center; display: flex; justify-content: center; } .upload-button { /* Used to position the input */ position: relative; /* Center the content */ align-items: center; display: flex; /* Border */ border: 1px solid #d1d5db; border-radius: 0.25rem; padding: 0.25rem 0.5rem; /* Demo */ width: 8rem; } .upload-button__input { /* Take the full size */ height: 100%; left: 0; position: absolute; top: 0; width: 100%; /* Make it transparent */ opacity: 0; } .upload-button__icon { margin-right: 0.5rem; } .upload-button__svg { fill: none; height: 1.5rem; stroke: #d1d5db; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1; width: 1.5rem; } ``` ```html index.html hidden
```