Use window.innerHeight to set div height in html -


i have 3 div , want fixed header , footer 100px height, , midle dinamic height related window inner height. wrote bellow lines in html doesn't work. can help? many thanks.

<div id="header" style="background-color:white;width:100px; height:12vh; margin: 0; padding: 0 ;border:0;"></div> <div id="map_canvas" style="background-color:black;width:window.innerheight-200;height:78vh;margin: 0; padding: 0 ;border:0"></div> <div id="footer" style="background-color:white;width:100px; height:10vh; margin: 0; padding: 0 ;border:0;bottom:0px"></div> 

window.innerheight javascript, not css.

if want #map_canvas element have width of 100vh (see viewport-percentage lengths) minus 200px can use css's calc() function:

<div id="map_canvas" style="...width: calc(100vh - 200px);..."></div> 

jsfiddle demo.

ideally shouldn't using inline styles though. should move styles a stylesheet:

div#map_canvas {     ...     width: calc(100vh - 200px); } 

i have feeling may have wanted height though, , not width... in case change width above height.

<div id="map_canvas" style="...height: calc(100vh - 200px);..."></div> 

jsfiddle demo using height instead of width.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -