我有一个父级<div>
。在里面我放了一些文本和图片。现在我需要缩放到该父<div>
的特定部分。是否可能?
我有一个父级<div>
。在里面我放了一些文本和图片。现在我需要缩放到该父<div>
的特定部分。是否可能?
如果您希望在鼠标悬停时放大该图像:
$(document).ready( function() {
$('#div img').hover(
function() {
$(this).animate({ 'zoom': 1.2 }, 400);
},
function() {
$(this).animate({ 'zoom': 1 }, 400);
});
});
如果使用缩放按钮,您可以这样做:
$("#ZoomIn").click(ZoomIn());
$("#ZoomOut").click(ZoomOut());
function ZoomIn (event) {
$("#div img").width(
$("#div img").width() * 1.2
);
$("#div img").height(
$("#div img").height() * 1.2
);
},
function ZoomOut (event) {
$("#div img").width(
$("#imgDtls").width() * 0.5
);
$("#div img").height(
$("#div img").height() * 0.5
);
}
zoom
。 - adamj@Gadde - 你的回答非常有帮助。谢谢!我需要一个类似于“Maps”的div缩放效果,而且能够在每次点击时重复缩放。通过你的帖子,我成功地实现了我需要的效果。下面是我的最终结果。
var currentZoom = 1.0;
$(document).ready(function () {
$('#btn_ZoomIn').click(
function () {
$('#divName').animate({ 'zoom': currentZoom += .1 }, 'slow');
})
$('#btn_ZoomOut').click(
function () {
$('#divName').animate({ 'zoom': currentZoom -= .1 }, 'slow');
})
$('#btn_ZoomReset').click(
function () {
currentZoom = 1.0
$('#divName').animate({ 'zoom': 1 }, 'slow');
})
});
$('image').animate({ 'zoom': 1}, 400);
使用zoom-master/jquery.zoom.js。图片的缩放效果非常完美。这是页面的链接。 http://www.jacklmoore.com/zoom/
<script>
$(document).ready(function(){
$('#ex1').zoom();
});
</script>