简体   繁体   English

CSS,jQuery:如何缩放图库?

[英]CSS, jQuery: How can I zoom a image gallery?

I have an image gallery which holds lots of inline-block containers (similar to a chess field). 我有一个图库,其中包含许多内联块容器(类似于国际象棋场)。 No when I use the browser zoom strg + mouse wheel the images get scaled so that I can see more or less depending on if I zoom out or zoom in. 否,当我使用浏览器的zoom strg +鼠标滚轮时,图像会缩放,以便根据放大还是放大来查看更多或更少。

My question now is how I can do this directly in jQuery (maybe with a slide) without using the browser zoom function? 我现在的问题是,如何在不使用浏览器缩放功能的情况下直接在jQuery中(可能带有幻灯片)执行此操作?

Is there an easy way to do this or do I have to change all widths heights? 有没有简单的方法可以做到这一点,还是我必须更改所有宽度的高度?

Regards 问候

The first question would be how much do you want to zoom the images and how big they are. 第一个问题是你多么想放大的图像,并有多大他们。 I'm asking because you will need to preload the images at their maximum resolution, could be slow with large images. 我问是因为您需要以最大分辨率预加载图像,对于大图像可能会很慢。

Assuming this is not an issue, what I would do is write my own function to animate both width and height; 假设这不是问题,我要做的是编写自己的函数来同时对宽度和高度进行动画处理。 I think there is no more straightforward way. 我认为没有其他更直接的方法。

Other than this, there are plenty of jQuery plugins out there: just Google them, I've found an interesting list on: http://www.tripwiremagazine.com/2011/10/jquery-image-zoom.html 除此之外,还有许多jQuery插件:仅是Google插件,我在以下网站上找到了一个有趣的列表: http : //www.tripwiremagazine.com/2011/10/jquery-image-zoom.html

Try also this, in compact form: 也可以尝试以紧凑的形式进行此操作:

$('#image').mouseover(function()
{
    $(this).animate({width: "300px", height: "300px"}, 'slow');
});
$('#image').mouseout(function()
{   
    $(this).animate({width: "200px", height: "200px"}, 'slow');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM