Reputation: 123
When I use direction:rtl
for the Arabic view, the details on the date are not in showing incorrect order.
E.g. in ltr
it's showing like 03 February 2016
but in rtl
it's wrongly aligned as February 2016 03
.
div {
font-size: 20px;
}
<div style="direction:rtl;">
03 February 2016
</div>
Is there any way to rectify it. Or it's just the natural way of showing date in the Arabic view?
Upvotes: 3
Views: 4296
Reputation: 17498
You can also use the dir attribute to assign rtl directionality. It makes your code much cleaner and easy to read.
div[dir='rtl'] {
float: left;
}
/*Only supported in Firefox*/
:dir(rtl) {
float: left;
}
<div dir="rtl">
15 ‫January‬ 2020
</div>
Upvotes: 0
Reputation: 347
this is common, if you use direction RTl you can view mirror image of text, so if you use arabic data it shows perfect.
Upvotes: 0
Reputation: 186
‫03 February ‬2016
solution works good for chrome. But it changes the output as 'mm ddyyyy' in firefox and IE.
Following works consistently in chrome, firefox and IE.
<div style="float:left; direction:rtl;">
15 ‫May‬ 2017
</div>
If you are working with angular js and want to apply the solution in date formatter then, you can write as below:
<div style="float:left; direction:rtl;">
{{ 1463725737789 | date: 'dd ‫MMM‬ yyyy'}}
</div>
Input in angular expression should be valid javascript date object. Given input '1463725737789' is time in milliseconds.
Upvotes: 2
Reputation: 328
Answering your next question:
<div style="float:left; direction:rtl;">
‫03 February ‬2016
</div>
Upvotes: 4
Reputation: 19186
You can change this behavior by adding Unicode Character 'LEFT-TO-RIGHT EMBEDDING' (U+202A) and ending it by POP.
<div style="direction:rtl;">
‪03 February 2016‬
</div>
Upvotes: 2