Change text direction for all pages

孤街浪徒 提交于 2019-12-06 02:16:36

问题


I am working on a web project that can be in multi langauges, i have done all of that, i still have one thing.

the pages when shows in english is from left to right.

some languages on my website needs to be from right to left

Note please, my question is about the whole page not the text in fields.

how can i do that please?

I am using this code for launching threads for many languages.

Thread.CurrentThread.CurrentCulture = new CultureInfo(CultureName);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

I don't know what i think that the previous code could be helpful in order to achieve my goal.


回答1:


bool Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft

See as example: http://afana.me/category/Website-Optimization.aspx?page=2

To flip the whole page use either HTML tag attributes

<body dir="rtl" align="right">

or CSS properties on body tag

direction:rtl; text-align:right;

Direction is to control BiDi for the language script. Align is used to control visual display alignment.




回答2:


You can use this code in _Layout to Change text direction for all pages: in body tag

<body dir="@(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft? "rtl" : "ltr")">




回答3:


I found this, hope it helps:

http://fortysevenmedia.com/blog/archives/styling_right-to-left_text_with_css_on_a_multi-lingual_site/

...and the site they made:

http://musicthoughts.com/

try the language links at the bottom.

They make use of the dir="rtl" attribute with some other minor changes to their css.



来源:https://stackoverflow.com/questions/19912475/change-text-direction-for-all-pages

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