Search code examples
jqueryheightscale

How to scale width on 100% heigh in jQuery?


I'm creating a jQuery online turn page and want my turn page to scale to fit the browser window. I want to do height 100% in my css but want to maintain the correct scale on the width so cant do 100% width.

Is there a way to do 100% height while maintaining the correct width of my turn page, it will be 2 A4 pages in a spread if that helps at all, here is the code I'm using atm to set a width.

 $(function() {
     $('#mybook').booklet({
         width:  1000,
         height: 650
     });
 }); 

I'm using the booklet jquery plugin.

Thanks in advance


Solution

  • Try multiplying height with width() * 0.65 to keep the aspect ratio.

    var width = 1000,
        height = width * 0.65;