为什么尾部标点符号在方向开头呈现:rtl? [英] Why is a trailing punctuation mark rendered at the start with direction:rtl?

查看:957
本文介绍了为什么尾部标点符号在方向开头呈现:rtl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更像是一种好奇心。在处理多语言Web应用程序时,我注意到某些字符,如块元素结尾处的标点符号(!?。;,),就像是放在开头,而不是当写方向是从右到左(



换句话说,字符串

 你好,世界! 

呈现为

 !当您放置在一个div块中时,! $ 

c> direction:rtl



如果文本被分为两部分并给出不同的颜色,最终呈现在两个独立的区域中:



http://jsfiddle.net/ 22Qk9 /



这种行为的意义是什么?我想这必须是一个特殊的(所有?)从右到左语言,这是由浏览器自动处理,所以我不需要关心它,或者我应该?


<原因是惊叹号!具有BiDi类ON [Other Neutrals],这意味着它有效地适应周围文本的方向性。在示例情况下,它因此放置在文本的左边。这对于从右到左书写的语言是相当正确的:终止标点符号出现在结尾,即在左边。



请使用CSS代码 direction:rtl 或者最好使用HTML属性 dir = rtl 从右到左,只为他们。



如果您改用 direction:rtl dir = rtl 只是为了特殊效果,像表格列从右到左布局,那么你需要考虑的影响。例如,在表的情况下,您需要为表的每个单元格设置方向 ltr (除非您希望将它们主要从左到右显示) 。



如果你有一个阿拉伯语文本块中引用的英语句子,那么你需要将包含英语文本的元素的方向性设置为 ltr ,例如

 < blockquote dir = rtl> Hello,World! ; / blockquote> 

一个类似的情况(仅在英文文本中使用阿拉伯语)在W3C文档中作为用例6讨论您需要了解有关Bidi算法和内置标记的信息(其中有一些奇怪的,虽然,像使用 cite 标记引用的文本,反对W3C的建议)。


This is more a sort of curiosity. While working on a multilingual web application I noticed that certain characters like punctuation marks (!?.;,) at the end of a block element are rendered as if they were placed at the beginning instead when the writing direction is right-to-left (as it is the case for certain Asian languages I do not speak).

In other words, The string

Hello, World!

is rendered as

!Hello, World

when placed in a div block with direction: rtl

This becomes even more evident if the text is split in two parts and given different colors: a contiguous chunk of text at the end is rendered in two separated regions:

http://jsfiddle.net/22Qk9/

What's the point of this behavior? I guess this must be a peculiarity of (all?) right-to-left languages which is automatically handled by the browser, so I don't need to care about it, or should I?

解决方案

The reason is that the exclamation mark "!" has the BiDi class ON [Other Neutrals], which means effectively that it adapts to the directionality of the surrounding text. In the example case, it is therefore placed to the left of the text before it. This is quite correct for languages written right to left: the terminating punctuation mark appears at the end, i.e. on the left.

Normally, you use the CSS code direction: rtl or, preferably, the HTML attribute dir=rtl for texts in a language that is written right to left, and only for them. For them, this behavior is a solution, not a problem.

If you instead use direction: rtl or dir=rtl just for special effects, like making table columns laid out right to left, then you need to consider the implications. For example, in the table case, you would need to set direction to ltr for each cell of the table (unless you want them to be rendered as primarily right to left text).

If you have, say, an English sentence quoted inside a block of Arabic text, then you need to set the directionality of an element containing the English text to ltr, e.g.

<blockquote dir=rtl>Hello, World!</blockquote>

A similar case (just with Arabic inside English text) is discussed as use case 6 in the W3C document What you need to know about the bidi algorithm and inline markup (which has a few oddities, though, like using cite markup for quoted text, against W3C recommendations).

这篇关于为什么尾部标点符号在方向开头呈现:rtl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆