--- category: Input created: '2019-11-16' description: Create an input add-on with CSS flexbox keywords: css flexbox, css input add-on thumbnail: /assets/css-layout/thumbnails/input-addon.png title: Input addon --- ## HTML ```html index.html
...
...
...
...
``` ## CSS ```css styles.css .input-addon { border: 1px solid #d1d5db; border-radius: 0.25rem; display: flex; } .input-addon__input { border: none; /* Take the remaining width */ flex: 1; } .input-addon__addon { /* Center the content */ align-items: center; display: flex; justify-content: center; } .input-addon__addon--prepended { border-right: 1px solid #d1d5db; } .input-addon__addon--appended { border-left: 1px solid #d1d5db; } ``` ```css placeholders.css hidden .circle { background: #d1d5db; border-radius: 9999px; height: var(--circle-size); width: var(--circle-size); } .circle--sm { --circle-size: 0.5rem; } .circle--md { --circle-size: 1.5rem; } .circle--lg { --circle-size: 4rem; } ``` ```css styles.css hidden body { align-items: center; display: flex; justify-content: center; } .input-addon { border: 1px solid #d1d5db; border-radius: 0.25rem; display: flex; /* Demo */ margin-bottom: 0.5rem; width: 16rem; } .input-addon__input { border: none; /* Take the remaining width */ flex: 1; /* Demo */ padding: 0.25rem; margin: 0 0.25rem; width: 5rem; } .input-addon__addon { /* Center the content */ align-items: center; display: flex; justify-content: center; /* Demo */ padding: 0.25rem; } .input-addon__addon--prepended { border-right: 1px solid #d1d5db; } .input-addon__addon--appended { border-left: 1px solid #d1d5db; } ``` ```html index.html hidden
```