Window Height:
Element Height:
| height_fix('#test', window); | |
| function height_fix(element, parent){ | |
| var woh = $(parent).height(); | |
| var eoh = $(element).height(); | |
| $(window).resize(function(){ | |
| var eh = $(element).height(); | |
| var wh = $(parent).height(); | |
| var wdiff = wh / woh; | |
| var nh = Math.round((eoh * wdiff)); | |
| $(element).height(nh); | |
| $('.log').text('Window Height: '+wh+'px'); | |
| $('.log1').text('Element Height: '+nh+'px'); | |
| }) | |
| } |
| body{ | |
| margin:40px; | |
| } | |
| #test{ | |
| width: 100%; | |
| height: 100px; | |
| background: #444; | |
| color: #fff; | |
| } |