Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome scrollWidth is different on rtl and ltr direction

I see a bug on google chrome. run the below html code on Chrome V 31

<!DOCTYPE html>
<html>
<head>
  <title>Chrome scrollWidth issue</title>
  <meta charset="utf-8">
</head>
<body style="direction: ltr;">
  <div style="overflow: auto; height: 100px; width: 800px; border: 1px solid red;">
    <div style="height: 150px; width: 1080px; background: blue;"></div>
  </div>
</body>
</html>

When I change the body direction from ltr to rtl, the scrollWith of the parent div is different. This is not occurred on FireFox V25 or Internet Explorer V10.

I report the issue on chrome issue tracker.

My question is how can I fix this with css or javascript?

like image 229
Omid Shariati Avatar asked Dec 29 '13 13:12

Omid Shariati


1 Answers

Try to use clientWidth in the child element and you'll get 1080 in both rtl and ltr, hope that's a good enough solution till they fix the bug on chrome.

like image 183
Lior Asta Avatar answered Oct 23 '22 16:10

Lior Asta