0

I have looked at: Understanding offsetWidth, clientWidth, scrollWidth and -Height, respectively

But it is not the case. For example,

.main {
   width: 400px;
   overflow: visible;
}

.main table {
  width: 600px;
}

<div class="main">

     <table>
         <thead><tr><th>Foo</th><th>Bar</th></tr></thead>
         <tbody>
              <tr><td>Row1</td><td>Hello</td></tr>
              <tr><td>Row2</td><td>World</td></tr>
         </tbody>

     </table>

</div>


---------------------------------------
|main                                 |
|      ----------------------------------------------------
|      | table                                            |
|      ----------------------------------------------------
|                                     |
|                                     |
---------------------------------------

the offsetWidth and scrollWidth of the main div element are the same: 400. They should be 400 and 600 respectively, right?

Community
  • 1
  • 1
Dave
  • 759
  • 2
  • 9
  • 31

1 Answers1

0

Appears to be working for me?

http://codepen.io/anon/pen/EZEzGB

alert("Scrollwidth: " + document.getElementById('main').scrollWidth + "OffsetWidth: " + document.getElementById('main').offsetWidth);

What are you using that is returning the wrong value?

mikeg542
  • 423
  • 3
  • 17