0

I have a div that dynamically scales based on the viewport size.

function zoomSquare() {
    var $square = $('.square');

    var viewportWidth = $square.parent().width();
    var squareWidth = $square.width();
    var desiredWidth = Math.round(viewportWidth * 0.95);
    var zoom = (desiredWidth / squareWidth);

    $square.css('zoom', zoom);
    $square.css('-moz-transform', 'scale(' + zoom + ')');
    $square.css(  '-o-transform', 'scale(' + zoom + ')');
}

// When the browser is resized
$(window).on('resize', function(){ zoomSquare(); });

// When the page first loads
$(document).ready(function(){
    zoomSquare();
});

http://jsfiddle.net/sarahwhatsup/YDwds/8/

I want have the parent set to auto to as the div scales, the divs underneath adjust their position. This works in Chrome, IE, Safari but for some reason I can't get this to work in Firefox. Anyone have any idea?

user1519225
  • 31
  • 2
  • 4

1 Answers1

1

You could change the height of the wrapper div.

$('.wrapper').css('height', squareWidth * zoom);

http://jsfiddle.net/YDwds/22/

abney317
  • 7,760
  • 6
  • 32
  • 56