javascript - three.js dom element makes the whole page gets larger -


i'm trying build 3d viewer three.js, has full height leaves space side panel. vertical layout works expected, append render's dom element, horizontal scroll bar appears.

attached minimal working example. expect see (black) canvas element , red body. after v.append(renderer.domelement), page gets larger (filled blue, html element) , horizontal scroll bar appears. seems page larger body.

see https://jsfiddle.net/5jnvt4jh.

has idea, may happening there? couldn't find margin or padding chrome , firefox. :).

mwe

<!doctype html> <html lang="de">     <head>         <meta charset="utf-8">         <style>             html {                 background-color: blue;             }              body {                 margin: 0px;                 height: 100vh;                 background-color: red;             }              #viewer {                 height: 100%;                 width: 80vw;                 background-color: green;             }         </style>          <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.min.js"></script>      </head>     <body>         <div id="viewer"></div>         <script>             var v = document.getelementbyid('viewer');             var renderer = new three.webglrenderer();             v.append(renderer.domelement);             renderer.setsize(v.clientwidth, v.clientheight);         </script>      </body> </html> 

change style of body to:

body {             margin: 0px;             height: 100vh;             background-color: red;             overflow:hidden;         } 

jsfiddle: https://jsfiddle.net/raushankumar0717/5jnvt4jh/2/


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -