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
How to change the background color of ion-header in ionic 2?
提问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
回答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 color
attribute which takes key from the $colors
map.
检查官方文档。有一个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>