Connecting Tech Pros Worldwide Forums | Help | Site Map

Can't find element's real width.

rohypnol's Avatar
Member
 
Join Date: Dec 2007
Posts: 54
#1: Jun 19 '09
I have the following html structure and style:

Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2.   #master {
  3.     width: 200px;
  4.     border: 1px solid black;
  5.     white-space: nowrap;
  6.   }
  7.   #container {
  8.     border: 1px solid red;
  9.   }
  10.   #list li {
  11.     display: inline;
  12.     border: 1px solid blue;
  13.   }
  14. </style>
  15.  
  16. <div id="master">
  17. <div id="container">
  18.   <ul id="list">
  19.     <li id="element1">content1</li>
  20.     <li id="element2">content2</li>
  21.     <li id="element3">content3</li>
  22.     <li id="element4">content4</li>
  23.     <li id="element5">content5</li>
  24.     <li id="element6">content6</li>
  25.   </ul>
  26. </div>
  27. </div>
Is there any way to get the real scrolling width of the #container or #list elements? On Firefox 3.0.x, I get 200px for scrollWidth, clientWidth and offsetWidth (and the getWidth() function in Prototypejs), but it's clearly visible that the real width on my screen is about 600px.



Thanks,
Tom

drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,580
#2: Jun 19 '09

re: Can't find element's real width.


I don't recall exactly what those do but 200px should be correct since it's contained in #master. The fact that they overflow the div, being inline, doesn't matter, I guess, since it is the div that would get the scroll and not the list itself.
Reply