CSS3 Scaling and Overflow
HTML
<div class="outer">
<img id="profile" src="https://www.placeholde.com/600x400" />
</div>
<button class="zoom orig">Original</button>
<button class="zoom x2">x2</button>
<button class="zoom x4">x4</button>
CSS
.outer {
width: 400px;
height: 300px;
overflow: auto;
text-align: center;
background: #eee;
}
.outer:before {
content:'';
display: inline-block;
vertical-align: middle;
height: 100%;
}
#profile {
/* -webkit-transform-origin: top left; -moz-transform-origin: top left; transform-origin: top left; */
-webkit-transition: all 1s; -moz-transition: all 1s; transition: all 1s;
}
.outer img {
vertical-align: middle;
}
.scale_x2 {
margin-left: 150px;
margin-top: -193px;
-webkit-transform: scale(2);
-moz-transform: scale(2);
-ms-transform: scale(2);
-o-transform: scale(2);
transform: scale(2);
}
.scale_x4 {
margin-left: 450px;
margin-top: 15px;
-webkit-transform: scale(4);
-moz-transform: scale(4);
-ms-transform: scale(4);
-o-transform: scale(4);
transform: scale(4);
}
JavaScript
$(function () {
$('.zoom').on("click", function () {
if ($(this).hasClass('orig')) {
$("#profile").removeClass();
} else if ($(this).hasClass('x2')) {
$("#profile").removeClass().addClass('scale_x2');
} else if ($(this).hasClass('x4')) {
$("#profile").removeClass().addClass('scale_x4');
}
});
});