Get element calculated client width - Javascript DOM

Javascript examples for DOM:Element clientWidth

Description

Get element calculated client width

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <title>min-max-with-calc</title> 
      <style>

div {/*from w  w w  . j a v  a 2 s .c  o m*/
   border: 2px solid blue;
   width: calc(6e18px + 100vw - 6e18px);
}


      </style> 
   </head> 
   <body translate="no"> 
      <div></div> 
      <script>
window.onresize = foo;
function foo() {
  let d = document.getElementsByTagName('div')[0];
  d.innerHTML = 'width is '+d.clientWidth+' px';
}
foo();
    
      </script>  
   </body>
</html>

Related Tutorials