You can easily achieve this using a combination of relative
and absolute
positioning on the parent and child elements like this:
.field {
position: relative;
display: inline-block;
}
.field__input {
padding-right: 40px;
}
.field__helper {
position: absolute;
right: 5px;
top: 4px;
color: #999;
font-size: 12px;
}
/* this is just fluff to make it look nicer */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
<div class="field">
<input type="text" value="find" class="field__input">
<span class="field__helper">1 of 5</span>
</div>
We use a relatively positioned parent (.fieldRow
) to wrap around the input
field. Then, we use a span
(.helper
) containing the text we want to display and using position: absolute;
we can position it to the right of the input
field. Last of all, we need a little padding on the right hand side of the input
to stop the inputted value from bleeding into our helper text.