Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: rtl input element with ltr insert

Tags:

html

css

I used rtl direction (for persian language) in html tag for whole document. But I have some input element for username or email address (as you know, these are english and must be ltr). I google and find some script for auto-direction. They worked, but if I have rtl placeholder for input, the placeholder text also will be ltr!
Can you guide me?
I want something like this:
[sample]: http://sumdroid.pe.hu/sample.jpg "please see this image"

whole document is rtl, placeholder is rtl, but input element insert is ltr.

like image 260
Parsa Avatar asked Jul 22 '26 19:07

Parsa


1 Answers

Using the browser specific pseudo calls to the placeholder should sort your issue out

input[type="text"]:-moz-placeholder {
    text-align: right;
}
input[type="text"]:-ms-input-placeholder {
    text-align: right;
}
input[type="text"]::-webkit-input-placeholder {
    text-align: right;
}

.input{
direction: rtl;
}

.input:focus{
  text-align: left;
  direction: ltr;
}
like image 112
Stewartside Avatar answered Jul 25 '26 12:07

Stewartside



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!