Giter Club home page Giter Club logo

icon-css-generator's Introduction

icon-css-generator

扫描图片目录生成图标css。

用法

图标图片目录示例:

icons
├─ add.png
├─ del.png
├─ A
   ├─ Add.png
   ├─ ServiceSupport.jpg
   ├─ window_icon_max.png

命令行

java -jar IconCssGenerator.jar images/icons icons_test.css

生成 icons_test.css

.icon-add {
  background: url(icons/add.png) no-repeat center center;
}
.icon-del {
  background: url(icons/del.png) no-repeat center center;
}
.icon-a-add {
  background: url(icons/A/Add.png) no-repeat center center;
}
.icon-a-servicesupport {
  background: url(icons/A/ServiceSupport.jpg) no-repeat center center;
}
.icon-a-window-icon-max {
  background: url(icons/A/window_icon_max.png) no-repeat center center;
}

Java API

示例:

ImageFileToIconCssGenerator generator = new ImageFileToIconCssGenerator();
generator.setCssRuleGenerator( new DefaultCssRuleGenerator() ); //使用 DefaultCssRuleGenerator
generator.setInputDir( new File("images/icons") );
generator.setOutputStream( new FileOutputStream(new File("icons_test.css")) );
generator.generate();
DefaultCssRuleGenerator

ImageFileToIconCssGenerator有一个方法setCssRuleGenerator,其参数类型为AbstractCssRuleGenerator,抽象了如何生成css选择器css声明块。内置了一个子类DefaultCssRuleGenerator实现:
css选择器

  • 目录名作为名字部分
  • 多个单词用横线连接
  • 小写

css声明块
使用以下模板:

{
  background: url(根路径/图片路径) no-repeat center center;
}

setRelativeBasePath方法可以设置background url的根路径。

icon-css-generator's People

Contributors

hulang1024 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.