与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吧!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java LineNumberReader。如果查询行为不正确,则返回readLine()   java包含了一个使用AndroidX的工具栏,这让我的应用程序崩溃了   JVM设置通过“java jar”运行应用程序的最佳实践   java如何获取ImageButton宽度   java Oracle SQLLDR实用程序无响应   列出Java获取对象的arrayList中最常见的元素   java使用带有FlowLayout的getContentpane对布局应用更改,但不起作用为什么?   在java中,我可以在画布上绘制画布吗?   编译游戏代码时发生java异常错误   从firestore获取java Webview失败   java将TableLayout中单元格的内容向右对齐   java无法在发布模式下启动活动(使用proguard安卓optimize配置)   java允许在线程期间进行GUI更新。睡觉   java如何对以变量为列表的列表进行排序   API URL上的java Google云端点异常