HTML 输入字段中的文本右对齐
我有一个 HTML 标记,其 maxlength 很短,但 value 属性很长。我希望显示的文本显示文本的结束(右侧),而不是开始(左侧)。
<input maxlength=10 value="A really really really long entry goes in here"/>
目前显示:
“A real r”,
而不是我希望它显示:
“es in here”
干杯,
伊恩
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您希望可见区域从右侧开始吗?您可以使用 css 和以下规则
input {direction:rtl;}
rtl
表示从右到左示例: http://jsbin.com/ilejo4
PS: html 中
maxlength
的值必须用引号引起来,并且您必须设置 <输入
的code>typeDo 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 leftexample: http://jsbin.com/ilejo4
PS: the value of
maxlength
in your html must be wrapped with quotes, also you have to set thetype
of theinput
如果只想显示信息,可以在div中放置一个span,在div中写入overflow:hidden、display flex、justify-content: flex-end;
If you only want to display information, what you can do is place a span inside a div, in the div write overflow:hidden, display flex, justify-content: flex-end;
将
style="text-align:right"
添加到输入标记。Add
style="text-align:right"
to the input tag.