简体   繁体   English

如何使用一张大图片将其分解成较小的部分以用于网站?

[英]How can I use one large image and break it apart into smaller pieces for a website?

So I've seen a method that several people seem to use where they have one large image (a master template image, if you will), and after that image is loaded, there is some sort of script or coding that can isolate individual parts of the image and use just that smaller part for an element such as a button. 因此,我看过一种方法,似乎有几个人使用它们来制作一张大图像(如果需要,可以使用主模板图像),并且在加载该图像之后,可以使用某种脚本或编码来隔离各个部分并仅将较小的部分用于按钮等元素。 Such is the case with the letter tiles on Words With Friends on Facebook. Facebook的“与朋友共度”中的字母拼贴就是这种情况。 I'm not talking about how to use Photoshop to separate them. 我不是在谈论如何使用Photoshop分隔它们。 I'm hoping for a web page on the matter as well will hopefully some tutorials or examples. 我希望与此有关的网页也希望有一些教程或示例。 I'm looking for something I can do with HTML, CSS, or JavaScript. 我正在寻找可以使用HTML,CSS或JavaScript执行的操作。 Or even jQuery. 甚至是jQuery。

Sorry I can't provide any code, since that's what I'm after, and I don't know exactly what this method is called either. 抱歉,我无法提供任何代码,因为这是我要的,而且我也不确切知道该方法的名称。

There's a CSS technique called spriting. 有一种称为spriting的CSS技术。 I've found the following article explains it brilliantly: 我发现以下文章对其进行了出色的解释:

CSS Sprites: What They Are, Why They're Cool, and How To Use Them CSS Sprites:它们是什么,为什么很酷,以及如何使用它们

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

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