Applying a scale transformation to an element results in the magnification being applied not only to the element itself but also to all of its children. This behavior is consistent across most browsers, except for IE (as far as I know).
In order to achieve your desired effect, you should only scale specific elements:
- Elements that are not
img
and do not contain any descendant img
elements.
This can be accomplished using jQuery:
$("button").click(function () {
$("*").each(function (index, value) {
var $this = $(value);
// Check if it's not an image and does not contain child images
if (!$this.is("img") &&
$this.find("img").length == 0) {
// Scale it up
$this.css({
'-webkit-transform': 'scale(1.5)',
'-moz-transform': 'scale(1.5)',
'-o-transform': 'scale(1.5)',
'-ms-transform': 'scale(1.5)',
'transform': 'scale(1.5)'
});
}
});
});
You can view this action live here.
Alternatively, you can also use:
$this.css('zoom', '1.5');
Instead of:
$this.css({
'-webkit-transform': 'scale(1.5)',
'-moz-transform': 'scale(1.5)',
'-o-transform': 'scale(1.5)',
'-ms-transform': 'scale(1.5)',
'transform': 'scale(1.5)'
});