Use window.innerHeight to set div height in HTML
我有三个
我尝试了以下操作但未成功:
1 |
如果希望
1 |
JSFiddle演示。
理想情况下,您不应使用内联样式。您应该将样式移动到样式表中:
1 2 3 4 | div#map_canvas { ... width: calc(100vh - 200px); } |
我觉得您可能想对
1 |
使用
您是否期望这样
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> InnerHeight <style> #header{ height: 100px; } #content{ background: gray; } #footer{ height: 100px; } </style> <script src="jquery.js"> </head> <body> <script type="text/javascript"> $(document).ready(function(){ $('#content').css('height',$(document).innerHeight()+200) }); </body> </html> |