从右到左文本 HTML 输入
对于我的网站,我需要提供阿拉伯语支持。其中一部分是提供输入文本框,当用户输入时,新字符必须附加到左侧,并且文本必须右对齐。
将 css 属性设置为
text-align:right
不起作用,因为我无法让光标移至左侧并在那里添加字母。所以我删除了该属性并添加了
direction:RTL
此处,光标移至左侧且文本右对齐。但新添加的字符没有附加到左侧。相反,它们仅被附加到右端。
我该如何解决这个问题?请帮忙..
例如,请参阅谷歌阿拉伯语页面搜索框。我需要确切的行为,尽管不是那些花哨的键盘图标等,http://www.google .com/webhp?hl=ar
For my website, i need to provide arabic support. Part of it is to provide input textboxes where when user types in, the new characters have to be appended to the left and the text has to be right aligned.
setting the css property to
text-align:right
didn't work, as i could not get the cursor to come to the left and add letters there. So I removed that property and added
direction:RTL
Here, the cursor came to the left and text was right aligned. but the newly added characters were not getting appended to the left. Instead they were getting appended to the right end only.
How do I fix this? please help..
For example, see the google arabic page search box. I need the exact behavior, although not with those fancy keyboard icon etc., http://www.google.com/webhp?hl=ar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您可以在输入上使用 dir="rtl"。是支持的。
You can use the dir="rtl" on the input. It is supported.
这是我能想到的:
direction:RTL
进行右对齐Here's what I can think of:
direction:RTL
for the RIGHT alignment这段代码就可以了。
This code will do.
只需使用此 CSS,即可将文本字段和光标位置从右更改为左。
Simply use this CSS, this will change your text field and cursor position from right to left.
仅使用
direction:RTL
,当在系统设置中切换到正确的键盘(例如阿拉伯语)时,新添加的字符将正确附加到左侧。Use only
direction:RTL
and when switched to a proper keyboard (e.g. Arabic) in the system settings, the newly added characters will correctly be appended to the left.除了方向:rtl 之外,Angular Material 特有的一个功能是:
这适用于 RLT 和 RLT。长期TR
A feature specific to Angular Material, in addition to direction: rtl, is :
This will work for both RLT & LTR
更好、更用户友好的方法是将
dir
属性设置为auto
。这样,如果用户输入英文文本,它将自动左对齐,如果他输入阿拉伯文本,它将自动右对齐
请参阅 此处了解有关
dir
属性的更多信息A better, more user-friendly way to do this is to set the
dir
attribute toauto
.This way if a user enters English text it will be left-aligned and if he enters Arabic text it will be right-aligned automatically
See here for more information on the
dir
attribute用于 css 中的输入。
Use on the input in css.
它适用于 Chrome 浏览器。
使用 div 元素并使其可编辑。
It works for Chrome browser.
Use a div element and make it editable.