任务是使用 CSS 从右到左方向显示文本。这是在 CSS Direction 属性的帮助下完成的。默认情况下,HTML 文档中的文本对齐设置为从左到右方向。要从右到左显示文本,我们只需将方向属性设置为“rtl”的值。
句法:
element_selector {
direction: rtl;
}
示例 1:
HTML
GeeksforGeeks
How to display text
Right-to-Left Using CSS?
This text goes from right to left.
HTML
GeeksforGeeks
How to display text Right-to-Left Using CSS?
This text goes from right to left.
Another line is added.
输出:
示例 2:在上面的代码中,如果我们在“p”元素中添加更多文本内容,我们会得到以下输出。注意两个结果中的效果。
HTML
GeeksforGeeks
How to display text Right-to-Left Using CSS?
This text goes from right to left.
Another line is added.
输出: