-1

I'm trying to modify JavaScript (jQuery, Google Maps v.3) to get the size of #mao_canvas only 80% of the screen height, but I can't undestand what to modify in tihs function. Can anyone help me with this? The basic idea is to get 80% height of #map_canvas.

$(function(){
  $("#map_canvas").css("height",$(window).height() + 'px');
  initialize();
});
mrserge
  • 199
  • 9
  • 2
    is this what you mean? $(function(){ $("#map_canvas").css("height",($(window).height()*80/100) + 'px'); initialize(); }); – Ori Price May 09 '14 at 23:28

1 Answers1

1

is this what you mean? $(function(){ $("#map_canvas").css("height",($(window).height()*80/100) + 'px'); initialize(); });

Ori Price
  • 3,593
  • 2
  • 22
  • 37
  • this should be a comment not answer – Susheel Singh May 09 '14 at 23:28
  • Exactly what I was looking for. Can you please explain, what is happening here: `height()*80/100) + 'px'` Why px is still there if we are talking about percents? – mrserge May 09 '14 at 23:30
  • the person who asked himself is confused – Susheel Singh May 09 '14 at 23:31
  • 1
    $(window).height() gives you the actual height in pixels at any given time. all you need to do is extract 80% from this value. then you'll get the actual pixel value of 80%. all there is left to do is add px to this actual value – Ori Price May 09 '14 at 23:32
  • Got it. And why this was not working? `$("#map_canvas").css("height","80%");` – mrserge May 09 '14 at 23:36
  • 1
    I meant clicking on th V sign on the answer:). regarding you new question - It should work if you build your html tags and css right. look at this: [link](http://stackoverflow.com/questions/15843391/div-height-set-as-percentage-of-screen). – Ori Price May 09 '14 at 23:39