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; } 

enter image description here

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.

jsfiddle sample.

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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -