CSS 如何更改 ionic 2 中 ion-header 的背景颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42641395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:27:53  来源:igfitidea点击:

How to change the background color of ion-header in ionic 2?

cssionic-frameworksassionic2ionic3

提问by Pawan

How to change the header color? I tried below but didn't succeeded

如何更改标题颜色?我在下面尝试但没有成功

 <ion-header>
  <ion-navbar danger>
    <ion-title>TITLE</ion-title>
  </ion-navbar>
</ion-header>

My variable.scss is:

我的 variable.scss 是:

$colors: (
  primary:    #387ef5,
  secondary:  #32db64,
  danger:     #f53d3d,
  light:      #f4f4f4,
  dark:       #222
);

回答by Yasir

You can change it globally if you want to in your variables.scssunder/in the theme folder:

如果您想variables.scss在主题文件夹下/中,您可以全局更改它:

$toolbar-background: blue;

For all the reference Ionic SASS Variables to override follow this link

对于要覆盖的所有参考离子 SASS 变量,请点击此链接

回答by Devansh sadhotra

 <ion-header>
  <ion-navbar color="color3">
    <ion-title></ion-title>
  </ion-navbar> 
</ion-header>

you can set your custom color in src/theme/variable.scss like this :

您可以在 src/theme/variable.scss 中设置自定义颜色,如下所示:

$colors: (
  primary:    #8B4789,
  secondary:  #32db64,
  danger:     #f53d3d,
  light:      #f4f4f4,
  dark:       #222,
  color1: #15c178,
  color2: #8B4789,
  color3 : #07904d,
  color4: #673665,
  brown: #B75E33,
  ycBlue: #638AF1
);

I hope this will work for you

我希望这对你有用

回答by Suraj Rao

Check the official docs. There is a colorattribute which takes key from the $colorsmap.

检查官方文档。有一个color属性从$colors地图中获取键。

<ion-header>
  <ion-navbar color="danger">
    <ion-title>TITLE</ion-title>
  </ion-navbar>
</ion-header>

回答by sebaferreras

Set the color like this:

像这样设置颜色:

<ion-header>
  <ion-navbar color="danger">
    <ion-title>TITLE</ion-title>
  </ion-navbar>
</ion-header>