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

val*_*alk 1 html css overriding right-to-left

不知怎的,在dir ="rtl"下的CSS覆盖(左|右)似乎不起作用.

要修复 - 在Chrome/Firebug中:仅在禁用"left"属性时,重写的"left"(在.dir_rtl #main_search_wrapper下)样式才会开始影响实际布局.

看起来像一个常见的浏览器bug?

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

<html>

<head>
 <style>
   #main_search_wrapper {
       display: inline-block;
       position: absolute;
       right: 0;
   } 

   .dir_rtl #main_search_wrapper {
       left: 0;               /* <-- This should override the above style */
   }
 </style>
</head>

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

</html>
Run Code Online (Sandbox Code Playgroud)

谢谢

Wes*_*rch 5

left不一定会覆盖right,它将使用这两个属性,基本上设置如下:

.dir_rtl #main_search_wrapper {
   right: 0;
   left: 0;  /* <-- This wont override the above style */
}
Run Code Online (Sandbox Code Playgroud)

试试这个:

.dir_rtl #main_search_wrapper {
    right: 0; 
    right: auto;   /* <-- This will override the above style for "right" */
}
Run Code Online (Sandbox Code Playgroud)