I need an input with € or $ currency inside. I have an input with padding (without padding I've no problems)
How I can do it with perfect vertical centering?
I tried this method without optimal results:
1) "Margin-top:auto" and "margin-bottom: auto" method:
div {position:relative}
input {padding: 1em}
.currency {
position:absolute;
right:0.4em;
height:50%;
top:0;
bottom:0;
margin-top:auto;
margin-bottom:auto
}
<div>
<input type="text">
<span class="currency">€</span>
</div>
2) Fixed height and margin-top negative:
div {position:relative}
input {padding: 1em}
.currency {
position:absolute;
right:0.4em;
height:3em;
top:50%;
margin-top:-1.5em;
}
<div>
<input type="text">
<span class="currency">€</span>
</div>
In both cases vertical align does not work perfect.
Any ideas?