css – 更改颜色导航栏标题Ionic 2

前端之家收集整理的这篇文章主要介绍了css – 更改颜色导航栏标题Ionic 2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个问题…我的颜色现在是白色的,我的代码是这样的:
  1. <ion-header >
  2. <ion-navbar>
  3. <ion-title>
  4. HELLO
  5. </ion-title>
  6. </ion-navbar>
  7. </ion-header>

使用此选项更改颜色很容易(主要,次要,危险,光线,黑暗)

  1. <ion-header >
  2. <ion-navbar danger>
  3. <ion-title>
  4. HELLO
  5. </ion-title>
  6. </ion-navbar>
  7. </ion-header>

但我的问题是当我想使用自定义颜色时.
有人知道如何解决它?
提前致谢.

最好的祝福.

解决方法

有两种方法可以执行此操作,具体取决于您是只想在一个页面中更改颜色,还是要在应用程序的所有页面中更改颜色:

1)在单页/视图中更改它

就像你可以看到here

To change the theme,just tweak the $colors map in your
src/theme/variables.scss file:

  1. $colors: (
  2. // ...
  3. newcolor: #55acee
  4.  
  5. )

然后在视图中使用它

  1. <ion-header>
  2. <ion-navbar color="newcolor">
  3. <ion-title>
  4. HELLO
  5. </ion-title>
  6. </ion-navbar>
  7. </ion-header>

2)在所有页面/视图中更改它

在这种情况下,您需要在variables.scss文件添加以下内容以覆盖Ionic的默认值:

  1. $toolbar-ios-background: #55acee;
  2. $toolbar-md-background: #55acee;
  3. $toolbar-wp-background: #55acee;

编辑

Hi,how can I add gradient in app/theme/app.variables.scss?

您可以在src / theme / variables.scss中添加要使用的颜色:

  1. $header-first-color: #AAAAAA;
  2. $header-last-color: #000000;

然后设置规则以使用它(如果要将其应用于每个页面,则在app.scss文件中;如果要将其应用于单个页面,则在page-name.scss文件中):

  1. ion-header {
  2. .toolbar-background {
  3. background: linear-gradient(135deg,$header-first-color 0%,$header-last-color 100%);
  4. }
  5. }

猜你在找的CSS相关文章