我正在尝试使用 CSS3 Transform (scale) 为容器创建放大功能,一切似乎都很好,但是当图像被缩放时,溢出只覆盖图像的一部分,左上角部分不在溢出。
代码如下:
HTML:
<div class="outer">
    <img id="profile" src="http://flickholdr.com/300/200/" />
</div>
<button class="zoom orig">Original</button>
<button class="zoom x2">x2</button>
<button class="zoom x4">x4</button>
CSS:
.outer          { width: 500px; height: 500px; overflow: auto; text-align: center; background: #eee; }
.outer:before   { content: ''; display: inline-block; vertical-align: middle; height: 100%; }
.outer img      { vertical-align: middle; }
.scale_x2   { -webkit-transform: scale(2); -moz-transform: scale(2); -ms-transform: scale(2); -o-transform: scale(2); transform: scale(2); }
.scale_x4   { -webkit-transform: scale(4); -moz-transform: scale(4); -ms-transform: scale(4); -o-transform: scale(4); transform: scale(4); }
JS:
$(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');
        }
    });
});
在这里检查小提琴:http: //jsfiddle.net/sbaydakov/RhmxV/2/
关于如何进行这项工作的任何想法,以便整个图像可见?
谢谢。