HTML 中的 RTL 布局错误 - CSS 覆盖不起作用

发布于 2024-12-24 16:29:29 字数 833 浏览 4 评论 0原文

不知何故,dir =“rtl”下的CSS覆盖(左|右)似乎不起作用。

对于 verigy - 在 Chrome / Firebug 中:仅当禁用“left”属性时,覆盖的“left”(在 .dir_rtl #main_search_wrapper 下)样式开始影响实际布局。

看起来像是一个常见的浏览器错误?

以下是以下代码的实时示例: http://jsfiddle.net/DwRLz/

#main_search_wrapper {
  display: inline-block;
  position: absolute;
  right: 0;
}

.dir_rtl #main_search_wrapper {
  left: 0;
  /* <-- This should override the above style */
}
<body class="dir_rtl" dir="rtl">
  <div id="main_search_wrapper" style="display: inline-block;">
    This should be aligned to the left.
  </div>
</body>

somehow the CSS overrides (left|right) under dir="rtl" don't seem to work.

To verigy - in Chrome / Firebug: only when disabling the "left" attribute, the overriding "left" (under .dir_rtl #main_search_wrapper) style starts affecting the actual layout.

Looks like a common browsers bug?

Here's a live example of the code below: http://jsfiddle.net/DwRLz/

#main_search_wrapper {
  display: inline-block;
  position: absolute;
  right: 0;
}

.dir_rtl #main_search_wrapper {
  left: 0;
  /* <-- This should override the above style */
}
<body class="dir_rtl" dir="rtl">
  <div id="main_search_wrapper" style="display: inline-block;">
    This should be aligned to the left.
  </div>
</body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

当梦初醒 2024-12-31 16:29:29

left 不一定覆盖 right,它会使用 both 属性,基本上像这样设置它们:

.dir_rtl #main_search_wrapper {
   right: 0;
   left: 0;  /* <-- This wont override the above style */
}

试试这个:

.dir_rtl #main_search_wrapper {
    right: 0; 
    right: auto;   /* <-- This will override the above style for "right" */
}

left doesn't necessarily override right, it will use both properties, basically setting them like so:

.dir_rtl #main_search_wrapper {
   right: 0;
   left: 0;  /* <-- This wont override the above style */
}

Try this:

.dir_rtl #main_search_wrapper {
    right: 0; 
    right: auto;   /* <-- This will override the above style for "right" */
}
盗心人 2024-12-31 16:29:29

尝试使用 bdo 标记。

<bdo dir='rtl'>
   ךלחיעכגדש(‫This text will go right-to-left.)ךלחיעכגדשךלחיעכגדשךלחיעכגדש
</bdo>

Try to use bdo tag if you want to align text left.

<bdo dir='rtl'>
   ךלחיעכגדש(‫This text will go right-to-left.)ךלחיעכגדשךלחיעכגדשךלחיעכגדש
</bdo>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文