项目作者: kevnk

项目描述 :
Common icons—customizable via LESS—that morph from one to another with CSS transition; inspired by (but not using) SVG animated icons.
高级语言: CSS
项目地址: git://github.com/kevnk/tricons.git
创建时间: 2015-08-14T22:12:40Z
项目社区:https://github.com/kevnk/tricons

开源协议:

下载


tricons

Common icons—customizable via LESS—that morph from one to another with CSS transition; inspired by (but not using) SVG animated icons.

Usage

TL;DR; for a full example, view src/index.html and src/styles/less/styles.less

1. Bower install

  1. $ bower install -S tricons

2. Import the tricons mixin

  1. @import 'bower_components/tricons/tricons';
  2. // Optionally set the default tricon
  3. // NOTE: if you change default-tricon, be sure to add/remove it from the list of @tricons below
  4. @default-tricon: hamburger-menu;
  5. // Optionally remove unused icons from this list to slim down on your CSS
  6. @tricons: hamburger-menu, x, arrow-left, arrow-right, arrow-up, arrow-down, plus, minus, loading, caret-up, caret-down, caret-left, caret-right, heart;
  7. // Optionally customize tricons default values
  8. @tricon-thickness: 2px;
  9. @tricon-min-width: 40px;
  10. @tricon-height: 40px;
  11. @tricon-pad-vert: 0;
  12. @tricon-pad-horz: 0;
  13. @tricon-color: #fff;
  14. @tricon-color-hover: #fff;
  15. @tricon-bg-color: #2A97EF;
  16. @tricon-bg-color-hover: saturate(lighten(#2A97EF, 5%), 5%);

3. Create some customized tricon buttons with your less

  1. .my-custom-tricon {
  2. @thickness: 1px;
  3. @min-width: 60px;
  4. @height: 60px;
  5. @pad-vert: 10px;
  6. @pad-horz: 20px;
  7. @color: #fff;
  8. @color-hover: #fff;
  9. @bg-color: #FEEA3A;
  10. @bg-color-hover: saturate(lighten(#FEEA3A, 5%), 5%);
  11. .tricon(@thickness, @min-width, @height, @pad-vert, @pad-horz, @color, @color-hover, @bg-color, @bg-color-hover);
  12. }

4. HTML Markup

  1. <a class="my-custom-tricon" href="#" data-tricon="hamburger-menu" data-tricon-toggle="x">
  2. <span></span>
  3. <span></span>
  4. <span></span>
  5. </a>
  6. <a class="my-custom-tricon" href="#" data-tricon="arrow-left">
  7. <span></span>
  8. <span></span>
  9. <span></span>
  10. <span>Text right of icon</span>
  11. </a>

NOTE: if you want the text on the left of the icon, just move that element before the 3 empty spans

5. Javascript to toggle data-tricon attribute

Use the following or roll your own:

  1. <script src="bower_components/jquery/dist/jquery.min.js"></script>
  2. <script src="bower_components/tricons/dist/tricons.js"></script>