ionic-item color and href not working
An ion-item
with a href
attribute renders differently. For more info on the why see dfsq's answer
What you could do is instead of using the ion-list
directive, use the classes:
<ion-content>
<ul class="list">
<a href="" class="item positive-bg" nav-clear menu-close ng-click="login()">Login</a>
<a href="#/app/search" class="item calm-bg" nav-clear menu-close>Search</a>
<a href="#/app/browse" class="item assertive-bg" nav-clear menu-close>Browse</a>
<a href="#/app/playlists" class="item balanced-bg" nav-clear menu-close>Playlists</a>
</ul>
</ion-content>
Demo on Codepen
Color Attribute not working in Heading inside ionic content tag
Use ion-text
directive on your element then apply color. It will work.
In your case it should be like this.
<h1 ion-text color="secondary">LOGO</h1>
<!-- and -->
<p ion-text color="danger">Sign in with social media account</p>
Why href inside button not working?
Drop the button and decorate the a
element with the class names.
<a href="www.google.com" class="button button-outline button-positive">fes</a>
hope this helps.
Change color of an ion-item on condition
The color will change based on your variable if you add square brackets around color.
<ion-note item-end [color]="!isShipButtonDisabled ? 'primary' : 'secondary'">
Adding the square brackets will tell angular to evaluate that expression.
Changing background color of Ionic ion-item in CSS
Ionic is injecting an element inside the <ion-item>
giving the element a structure of:
<ion-item>
<div class="item-content">
</div>
</ion-item>
The Ionic CSS contains a CSS property:
.item-content {
background-color:#ffffff;
}
The inline CSS you added is being applied to the element behind the element with the #ffffff
background, so you can't see your background color.
Apply the background color to the .item-content
element, as @ariestiyansyah recommended by adding the following CSS to the Ionic CSS file, or create a custom CSS file and include a <link>
to it in the header, with the following:
.item .item-content {
background-color: transparent !important;
}
Here's the working demo.
Ionic 4: ion-item background transparent has no effect
Update:
Finally found the cause for that weird behaviour. Looks like the .list-ios on ion-list was the malefactor.
This did the trick for me:
ion-list {
background: transparent;
ion-item {
--background: inherit;
}
}
How to change only one ion-item color in ion-list when clicked?
Take a Variable and check index of your *ngFor
if item gets clicked change color.
.ts
selectedItem: any;
.html
<ion-item *ngFor="let exercise of exercisesArray; let i = index" (click)="onClick(exercise); selectedItem = i" [ngStyle]="{color: selectedItem == i ? YourNewColor : null}">
{{exercise.title}}
</ion-item>
update you selectedItem
variable when Item gets clicked and check it in your ngStyle
to apply new Color.
Change ion-item background color in Ionic 4.0
Use this special ionic CSS rule:
ion-item{
--ion-background-color:#fff;
}
Related Topics
CSS Background Color Extend as Far as Text
How to Prevent a Flex Item Height to Overflow Due to It's Content
What Does "Body > *" Mean in CSS
How to Hide or Show Content with CSS Depending on Screen Size
Flexslider Fades But Will Not Slide
Font Color in HTML Email - Gmail
How to Implement a CSS-Only Fallback for Background-Size
Pointer Events: None, Filter, Works in Ie8 and Anywhere, Not Ie9
Clearfix with Twitter Bootstrap
Why Does Ie10 Require The Presence of a P:Hover {} Rule for Transitions to Work on a Pseudo Element
Negative Left and Right Margin of .Row Class in Bootstrap
Fixed Div Overlaps Scrollbar of Static Div
How to Add Multiple Classes to Markdown Using Jekyll
What Is Result of Calc() in CSS
Loading Global SASS Files in Multiple Compass Projects
How to Set Div Height to 100% of Chosen Print Paper
Label: Hover Attribute Triggers Incorrect Element in Ie10 and Ie11