Right align text in HTML input field

断了今生、忘了曾经 提交于 2019-12-06 19:16:50

问题


I have an HTML tag with a short maxlength but a long value attribute. I'd like the displayed text to show the end (right side) of the text, rather than the start (left side).

<input maxlength=10 value="A really really really long entry goes in here"/>

currently shows:

"A really r"

instead I'd like it to show:

"es in here"

Cheers,

Ian


回答1:


Do you want the visible area to start from the right? you can use css and the following rule input {direction:rtl;}

rtl means from right to left

example: http://jsbin.com/ilejo4

PS: the value of maxlength in your html must be wrapped with quotes, also you have to set the type of the input




回答2:


Add style="text-align:right" to the input tag.



来源:https://stackoverflow.com/questions/4973500/right-align-text-in-html-input-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!