你如何映射上图标的区域设置按钮? [英] How do you map areas on icon set to buttons?
问题描述
我想使用一个登录按钮集(科莫媒体提供)为我的ASP.NET MVC3网站和指定的图标对应的按键,但按键集是一个单一的形象:结果
除了用图像编辑器进出分裂图标放到单独的图像文件,有没有办法用code办呢?我知道类似的事情与计算器按钮标记做了,但我不知道该怎么做同样的事情编程(不知道正确的任期任):结果
I want to use a login button set (courtesy of Komodo Media) for my ASP.NET MVC3 website and assign the icons to the corresponding buttons, but the button set is a single image:
Aside from going in with an image editor and splitting the icons out into separate image files, is there a way to do it with code? I know that a similar thing is done with the stackoverflow markup buttons, but I don't know how to do the same thing programatically (not sure of the proper term either):
什么是地图图像的不同部分,以单独的按钮的正确方法?
What's the proper way to "map" the different parts of image to separate buttons?
推荐答案
这是一个 CSS精灵。斯科特Hansleman 博客了。我个人一直使用雪碧和图像优化框架在许多项目中。
That's a CSS sprite. Scott Hansleman blogged about it. Personally I have been using the Sprite and Image Optimization framework in many projects.
例如在剃刀,你可以简单地使用下面的帮助:
For example in Razor you could simply use the following helper:
@Sprite.Image("~/App_Sprites/facebook.png")
将使用CSS背景定位技术呈现从单一的雪碧正确的图像。
which will render the correct image from the single Sprite using CSS background positioning technique.
这篇关于你如何映射上图标的区域设置按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!