Finding a layer's width when the CSS is not set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    Finding a layer's width when the CSS is not set

    Does anyone know a trick to get the width of a layer when its CSS width attribute is not set? The code below will return a value of null since the CSS attributes are not set. Does anyone know of a way to get the layer's width in this case?


    Code:
    <div id="someLayer" ></div>
    
    <script>
        alert('Width: 'document.getElementById('someLayer').style.width):
    </script>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    It should inherit the width of the nearest ancestor element, where this property is defined. if there's no width defined, it will take window width minus margins, paddings, borders and offsets.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Perhaps this is what you're looking for.

      Comment

      Working...