2012-01-03 78 views
1

莫名其妙的CSS覆蓋(左|右)在DIR =「RTL」似乎並不管用。在Chrome/Firebug中:只有在禁用「left」屬性時,重寫的「left」(在.dir_rtl #main_search_wrapper下)樣式開始影響實際佈局。錯誤RTL佈局HTML - CSS覆蓋不起作用

看起來像一個普通的瀏覽器錯誤?

這裏是下面的代碼的一個活生生的例子: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> 

感謝

+0

不重寫,只需添加。你的div有'left:0;'AND'right:0;' – 2013-03-15 11:29:38

回答

5

left不一定覆蓋right,它將使用性質,基本上設置它們像這樣:

.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" */ 
} 
+1

謝謝!我所做的並不是重寫,而是添加了一個新的屬性,這就是爲什麼它不工作:) – valk 2012-01-03 08:17:25