ionic3主题设置之进阶篇

175 篇文章 1 订阅

原文出处:https://www.jianshu.com/p/e0e39fea3ae2 (原文更易阅读)

前言:因为我们是在theme/variables.scss建立了两个不同的主题,但是主题里的内容80%到90%是一样的,由此我们可以优化一次sacc代码;
例子如下:

1、在theme下面建立一个common.css,这里用于存放公共的scss

//tool-bar
.toolbar-ios-primary .toolbar-background-ios{
  background: $primary;
}
//tab
.tab-button[aria-selected=true] {
  color: $primary !important;
}
.tabs-ios .tab-button[aria-selected=true] .tab-button-icon{
  color: $primary !important;
}
//  button
.button-ios-primary{
  background-color: $primary;
}
.button-outline-ios{
  color: $primary;
  border-color: $primary;
}
.button-ios-primary.activated{
  background-color: $primary;
}
//segment-md
.segment-md .segment-button.segment-activated{
  border-color: $primary !important;
  color: $primary !important;
}

2、在theme/variables.scss引入公共方法,并给变量赋值, common.scss一定要引入两次,并且是在class里引入,否则会报错找不到变量,common.scss里只引用变量,变量没有在里面赋值。
(由于scss不能像jq一样写公共方法,所以这里用一个class包住)

.default-theme {
  $primary: #488aff;
  @import "common";
}
.pink-theme {
  $primary: #FFB6C1;
  @import "common";
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值