How do I make an input text using CSS, with a dashed bottom border/line that the length of strokes are equal to the length of each character?
Here's an example:

Try using border-bottom: 1px dashed black;
dashed border style doesn't give the exact effect because we cannot control the length of strokes. Instead, we can make the dashed border by using an absolutely positioned pseudo-element behind the input, and specify the space between strokes by letter-spacing property.
input[type="text"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 0;
outline: 0;
background: transparent;
width: 12.70em;
font-size: 1em;
}
.input-wrapper, input[type="text"] {
font-family: monospace;
font-weight: bold;
letter-spacing: .3em;
}
.input-wrapper {
display: inline-block;
position: relative;
overflow: hidden;
padding-bottom: .2em;
font-size: 200%;
}
.input-wrapper:after {
content: "——————————————————————————————";
line-height: .3em;
position: absolute;
bottom: 0;
left: 0;
z-index: -1;
}
<div class="input-wrapper">
<input type="text" value="Hello World" maxlength="15">
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With