与cli工具绑定以生成css精灵的库。
Ponytile的Python项目详细描述
创建css精灵的python库/实用程序。
这个图书馆是我因找不到一个 完全符合我的想法。也因为我发现了写作的想法 非常有趣:)
现在第一个版本完成了,我不知道我是否会推动开发 更进一步。不要在生产中使用这个,除非你准备好深入研究 自己编写和维护应用程序。
用法
ptl源文件
所有内容都是从ptl源文件生成的。它有几个选项:
[css] # The prefix that will be put in front of every generated CSS selector. # The selectors are generated from the file names. With the current # configuration, what you'd get for a toto.png file would be a # .icon-toto class. prefix = .icon- # This is a selector of the global class for all generated tiles (it # sets some styles attributes for everybody) general_selector = [class^="icon-"], [class*=" icon-"] [sprite] # A hint of the number of tiles that fits in the width of the sprite. width = 15 # The relative path from the generated CSS file to the generated sprite # file. This sprite file will be generated at compilation time. filename = sprite.png # A valid PIL format name format = PNG [tile] # This is a hint about the tiles size. Put here your most common tile # size, or the LCM of your tiles sizes, or something in that mood. width = 16 height = 16 [files] # Here goes a plain glob list of files to be put in the sprite. The # path is relative to the .ptl file. sprite/*.png
cli工具
一旦获得了ptl源代码,编译就非常简单:
ponytile input.ptl output.css
它将生成带有适当sprite文件的output.css文件 由ptl文件配置。
在网页中使用
只需将生成的css包含在某个地方,然后执行以下操作:
<i class="icon-toto"></i>
这应该是个诀窍:)
使用库
打开bin/ponytile并查看事情是如何完成的。没有什么比这更重要的了 现在就说说公共api吧!
版权所有
这整件事都是在wtfpl下授权的(见附件license.txt 文件)。