显示图像的一部分 [英] Show part of an image

查看:130
本文介绍了显示图像的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery或其他JavaScript技术显示图像的一部分?

How can I show a part of the image using jQuery or another JavaScript technique?

示例:

image:
[                ]
[     --------   ]
[     -      -   ]
[     - part -   ]
[     -      -   ]
[     --------   ]
[                ]


推荐答案

操纵CSS属性 background ,如这个

#imgDiv {
    background-image: url(image.jpg);
    background-position: 10px 50px; /* Visible coordinates in image */
    height: 200px; /* Visible height */
    width: 200px; /* Visible width */
}

以下是的方法。动画可见部分: http://jsfiddle.net/wGpk9/2/

这篇关于显示图像的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆