我正在使用Ionic 4.12我正在使用选项卡组件,当我激活该选项卡时,我想更改离子图标svg的颜色。我正试图改变离子标签按钮的阴影dom的文档显示与
--颜色选择
--背景聚焦
在CSS中,但它不会改变它
标签条形码
<ion-tab-bar slot="bottom">
<ion-tab-button tab="mainview">
<ion-icon src="assets/logo/mainView.svg"></ion-icon>
<ion-label>INDICADORES</ion-label>
</ion-tab-button>
<ion-tab-button tab="profile">
<ion-icon src="assets/logo/profile.svg"></ion-icon>
<ion-label>PERFIL</ion-label>
</ion-tab-button>
<ion-tab-button tab="">
<ion-icon src="assets/logo/phone.svg"></ion-icon>
<ion-label>LLAMAR</ion-label>
</ion-tab-button>
<ion-tab-button tab="caregivers">
<ion-icon src="assets/logo/doc.svg"></ion-icon>
<ion-label>CUIDADORES</ion-label>
</ion-tab-button>
<ion-tab-button tab="help">
<ion-icon src="assets/logo/help.svg"></ion-icon>
<ion-label>AYUDA</ion-label>
</ion-tab-button>
当前css的图标
ion-tab-button{
font-size: 10px;
--padding-end: 0px;
--padding-start: 10px;
--padding-bottom: 0px;
--margin-left:0px;
--margin-right:0px;
max-width:100px;
ion-icon{
font-size: 67.5px;
}
7条答案
按热度按时间wsxa1bj11#
这是正确的离子方式
7xllpg7q2#
如果你想在一个类处于活动状态时给予它另一种颜色,你可以简单地做以下事情:
但是,在您的情况下,这将是:
颜色属性也适用于十六进制和RGB代码(更多信息请参见https://www.w3schools.com/cssref/css_colors_legal.asp)
我也reccomend检查这篇文章,因为这是有关的问题,你有在目前。Editing Ionic tab icon styles
col17t5w3#
这是下面的CSS,如果我们只需要将样式应用于特定页面,我们需要将其添加到组件级CSS中。
使用focus伪类,我们可以将样式应用到选中的离子标签按钮上
u4dcyp6a4#
这比它应该的要难得多,但这对我来说是有效的:
nzkunb0c5#
您可以提供自定义CSS到选定的选项卡。每当您选择选项卡时,“选项卡选择”类将添加到离子选项卡按钮中。
dwthyt8l6#
在ionic中还有一种自定义选项卡的方法。(我的离子版本6.12.0)
uttx8gqw7#
我知道我迟到了四年,但我一直在寻找这个问题的答案,我花了一些时间才找到答案。唯一对我有效的是这个,所以我希望它能帮助到别人:
tab-label是
<ion-label>
标签的类,tab-icon用于<ion-icon>
,tab-button用于<ion-tab-button>
所有--color-selected的东西都只是在我点击按钮时改变涟漪的颜色,或者什么都不做。它在我的浏览器(Chrome)上工作,我也在我的手机(Android)上测试了它。
@离子/Angular 6.3.9