ionic3 自定义图标及应用

2018-03-13  本文已影响0人  咔簌

生成图标

项目应用 (底部附有完整代码)

image.png
image.png
image.png

另外,有几点需要注意的

  1. 文件中的yes是个人添加的前缀,在图标应用的时候应加上这个前缀,例如

<ion-tab [root]="tab1Root" tabTitle="我的名片" tabIcon="yes-my-cart"></ion-tab>

  1. 名字和code一定要对上


    image.png
@font-face {
  font-family: 'icomoon';
  src:  url('../assets/fonts/icomoon.eot?m120q3');
  src:  url('../assets/fonts/icomoon.eot?m120q3#iefix')       format('embedded-opentype'),
  url('../assets/fonts/icomoon.ttf?m120q3') format('truetype'),
  url('../assets/fonts/icomoon.woff?m120q3') format('woff'),
  url('../assets/fonts/icomoon.svg?m120q3#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}

  [class^="ion-ios-yes"], [class*=" ion-ios-yes"] ,
  [class^="ion-md-yes"], [class*=" ion-md-yes"]
{
/* use !important to prevent issues with browser       extensions that change fonts */
  font-family: 'icomoon' !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

/* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@mixin makeIcon($arg, $val) {
  .yes-#{$arg}:before,
  .ion-ios-yes-#{$arg}:before ,
  .ion-md-yes-#{$arg}:before   {
    content: $val;
    // font-size: 26px;
  }
}

@mixin makeOutlineIcon($arg, $val) {
   .yes-#{$arg}:before ,
   .ion-ios-yes-#{$arg}:before ,
   .ion-ios-yes-#{$arg}-outline:before ,
    .ion-md-yes-#{$arg}:before ,
    .ion-md-yes-#{$arg}-outline:before  {
    content: $val;
  //   font-size: 26px;
  }
}



@include makeOutlineIcon(arrow-back,'\e900');
@include makeOutlineIcon(arrow-forward,'\e901');
@include makeOutlineIcon(list,'\e902');
@include makeOutlineIcon(wx,'\e903');


@include makeIcon(arrow-back,'\e900');
@include makeIcon(arrow-forward,'\e901');
@include makeIcon(list,'\e902');
@include makeIcon(wx,'\e903');
上一篇 下一篇

猜你喜欢

热点阅读