A code snippet for forms by creating a HTML input with a visual, non-editable prefix. Sourced under a permissive license.
CSS and HTML code for forms by creating a HTML input with a visual, non-editable prefix
<div class="input-box">
<span class="prefix">+30</span>
<input type="tel" placeholder="210 123 4567"/>
</div>
<style>
.input-box {
display: flex;
align-items: center;
max-width: 300px;
background: #fff;
border: 1px solid #a0a0a0;
border-radius: 4px;
padding-left: 0.5rem;
overflow: hidden;
font-family: sans-serif;
}
.input-box .prefix {
font-weight: 300;
font-size: 14px;
color: #999;
}
.input-box input {
flex-grow: 1;
font-size: 14px;
background: #fff;
border: none;
outline: none;
padding: 0.5rem;
}
.input-box:focus-within {
border-color: #777;
}
</style>
Tags: CSS, HTML, CSS, CSS code snippet, html code snippet, flex-grow, focus-within, placeholder
Image: Unsplash license
CC BY 4.0 added intro and tags – 30 Seconds of Code






