html - Right align text in <input> with letter-spacing -
if left align text in input, stays left aligned, no matter how set letter-spacing. if right align text in input, letter-spacing can push away right edge. example (shows in firefox, chrome):
<input class="left" value="spacing" /> <input class="right" value="spacing" />
css:
input { font-size:24pt; letter-spacing: 20px; } .left { text-align:left; } .right { text-align:right; }
is there way increase letter-spacing while remaining right-aligned?
you can use javascript , shadow dom in browsers support (can use: shadow dom, not many browsers currently). can use webcomponentsmonkeypatch future-proof implementation.
js:
var button = document.queryselector('input.right'); var shadowdom = button.webkitcreateshadowroot(); shadowdom.innerhtml = '<div style="margin-right: -20px;">'+button.value+'</div>';
html:
<input class="left" value="spacing" /> <input class="right" value="spacing" />
css:
input { font-size:24pt; letter-spacing: 20px; width: 70%; } .left { text-align:left; } .right { text-align:right; }
Comments
Post a Comment