Is there a way to make the background of an ionic 2 <ion-item> be transparent?
I have tried this CSS but it doesn't make the item transparent:
.list .item, .item-content .item-inner .item-block .item-ios
{
background: transparent !important;
}
ADDED CODE
My HTML looks like this:
<ion-content class="pu-my-plans-background">
<div *ngIf="hasPlans">
<ion-list no-lines class="pu-item-list">
<!--<ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)">-->
<ion-item-sliding *ngFor="let plan of plans; let i = index" >
<ion-item class="pu-section-list-item pu-my-plans-item" (click)="editPlan(plan.id, plan.rev, plan.title, i)">
{{ plan.title }}
<br>
<span class="pu-my-plans-plan-date">{{ plan.updated}}</span>
<button *ngIf="plan.important" ion-button clear item-right>
<ion-icon name="ios-alert-outline"></ion-icon>
</button>
</ion-item>
<ion-item-options side="right">
<button ion-button color="danger" (click)="deletePlan(plan.id, plan.rev)">
<ion-icon name="delete"></ion-icon>
Delete
</button>
</ion-item-options>
</ion-item-sliding>
<!--</ion-item-group>-->
</ion-list>
</div>
</ion-content>
And my CSS like this:
page-my-plans {
}
.pu-my-plans-plus-circle {
display: block;
//border: 2px solid white;
background-color: $pu-orange;
border-radius: 50%;
height: 38px;
width: 38px;
}
.pu-my-plans-plus-circle span {
font-size: 38px;
font-weight: 100;
color: white;
position: absolute;
top: -7px;
left: 8.5px;
}
.pu-plan-addButton {
font-size: 30px;
margin-right: 14px;
margin-top:-2px;
}
.pu-section-list-item{
color: white;
background-color: black;
font-weight:$pu-item-font-weight;
font-size:$pu-item-font-size;
padding-left:20px;
padding-right:0px;
}
.item{
background: transparent !important
}
// THEMING CSS
// ===========
//
.pu-my-plans-background {
background-image: url("../assets/img/my_plan_bg#2x.png");
background-size: cover !important;
}
.pu-my-plans-item {
border-style:solid;
border-bottom-width: 2px;
border-bottom-color: $pu-orange;
}
.pu-my-plans-plan-date {
color: $pu-orange;
font-size: 11px;
font-weight: 200;
}
I have tried every combination of styling the ionic 2 items as I can think of but the best I can get with this is to get a white background behind the ion-item. The ion-content has an image background but I can't get to see this through the ion-item.
Here is a solution in Ionic 4:
HTML:
<ion-list class="bg-transparent">
<ion-item color="none" lines="none">
Some random text
</ion-item>
<ion-item color="none" lines="none">
Some random text
</ion-item>
</ion-list>
CSS:
.bg-transparent {
background: transparent;
}
Important things to note:
Set background color of the main list to transparent by applying the class and adding CSS as shown.
Add the color="none" attribute to each of the ion-item.
lines="none" remove the lines under each of the ion-item
That should do it!
For Android
.item-md {
background: transparent;
}
For iOS
.item-ios {
background: transparent;
}
Try this in Ionic 5 using CSS Custom Properties.
For ion-item
ion-item {
--ion-item-background: transparent;
}
For ion-list
ion-list {
--ion-item-background: transparent;
}
For the ionic 2 item sliding background color you can change the main sass variable
$item-ios-sliding-content-background(transprent);
$item-md-sliding-content-background(transprent);
In your src -> theme -> variables.scss file
you can find all the variables here
You are using sliding item. Try using the below code
.pu-item-list ion-item-sliding{
background: transparent !important;
}
Try this:
<ion-item color="transparent">
</ion-item>
This worked for me.
ion-item {
--ion-item-background: transparent;
box-shadow: none !important;
}
ion-list {
--ion-item-background: transparent;
box-shadow: none !important;
}
Create a new variable in variable.scss like this:
--ion-color-transparent: rgba(0, 0, 0, 0.0);
and use it like this:
<ion-item color="transparent" padding="0px"><ion-input type="email" placeholder="username"></ion-input></ion-item>.
Related
I have ngx-daterangepicker-material in my angular8 app. It's working fine but it is showing vertically for now. I want to show it horizontally and also want to change the styles of date range picker.
I have this in my component.html
<app-content-overlay [dropshadow]="true" [showArrow]="true" [showArrow]="true" right="-32%" arrowRight="40px">
<ng-template appTemplate="item">
<span class="px-2">Date:
<input type="text"
ngxDaterangepickerMd
[autoApply]="options.autoApply"
[locale]="locale"
[showDropdowns]="true"
startKey="start"
endKey="end"
[(ngModel)]="selected"
[minDate]="minDate"
[maxDate]="maxDate"
[closeOnAutoApply]="options.closeOnAutoApply"
firstMonthDayClass="first-day"
lastMonthDayClass="last-day"
emptyWeekRowClass="empty-week"
lastDayOfPreviousMonthClass="last-previous-day"
firstDayOfNextMonthClass="first-next-day"
[timePicker]="timePicker"
[dateLimit]="dateLimit"
name="daterange" (change)="change($event)" class="border-none p-0"/>
<!-- <span *ngIf="filter?.techs?.selected?.length === 0">{{filterTitle?.techs?.all}}</span>
<span
*ngIf="filter?.techs?.selected?.length === 1">{{helperService.firstNameAndLastInitial(filter?.techs?.selected[0].name)}}</span>
<span *ngIf="filter?.techs?.selected?.length > 1">Multiple</span> -->
</span>
</ng-template>
</app-content-overlay>
But it's showing like this
i tried to change styling of this daterangepicker like this in component.scss
.md-drppicker{
top: 37px !important;
left: -98px !important;
right: auto !important;
width: 500px !important;
}
But my styling is not overriding the default styling. how can i do that?
This works, at least for now, before ng-deep goes away
::ng-deep {
ngx-daterangepicker-material {
& {
.md-drppicker {
min-width: 640px !important;
top: 45px !important;
&.double {
.calendar {
td {
&.active {
background-color: ........;
border-radius: ........;
color: ...........;
&.off {
background-color: ........ !important;
border-color: ....... !important;
color: ........ !important;
}
}
}
.....
In my IONIC 4 application I am trying to vertical-align a div inside an ion-row / ion-col element. This kinda works but the second ion-col, which has an ion-icon inside it, messes up the height of the row (which is visible by it's borders).
So I have the following html setup (only showing the bit that matters):
<ion-content>
<ion-row class="top-icons ion-text-center">
<ion-col class="ion-padding">
<div class="element-color" [style.backgroundColor]="getColorString(el)"></div>
</ion-col>
<ion-col class="ion-padding">
<ion-icon name="warning" color="danger" *ngIf="el.IsCcp"></ion-icon>
<ion-icon name="cog" *ngIf="!el.IsCcp"></ion-icon>
</ion-col>
</ion-row>
.. Other stuff
The sccs of the html:
.top-icons > ion-col {
border-top: 1px solid var(--ion-color-lightGray);
border-bottom: 1px solid var(--ion-color-lightGray);
.element-color {
width: 22px;
height: 22px;
border-radius: 7px;
margin: 0 auto;
}
ion-icon {
font-size: 1.7em;
padding-top: 2px;
}
&:first-child {
border-right: 1px solid var(--ion-color-lightGray);
}
}
.title {
font-size: 1.1rem;
}
p {
margin: 5px 0;
font-size: 0.9rem;
}
Which results in the following, the problem however is that the div is not vertical-aligned in the ion-col element, while the ion-icon is:
When taking a closer look it gets obvious that the div is not getting vertically aligned in the ion-col:
I thought I could fix this with the IONIC css utility ion-align-items-center on the ion-row:
<ion-content>
<ion-row class="top-icons ion-text-center ion-align-items-center">
<ion-col class="ion-padding">
<div class="element-color" [style.backgroundColor]="getColorString(el)"></div>
</ion-col>
<ion-col class="ion-padding">
<ion-icon name="warning" color="danger" *ngIf="el.IsCcp"></ion-icon>
<ion-icon name="cog" *ngIf="!el.IsCcp"></ion-icon>
</ion-col>
</ion-row>
.. Other stuff
Which results in the following, but unfortunately introduces a new problem:
So now the div is vertical aligned but the ion-col itself has been moved in comparison to the other ion-col:
This can be fixed by changing the font-size of the ion-icon back to its original font but this makes the icon way to small.. :
Any ideas how to get this to work?
I'm trying to use ion-skeleton inside an ion-item. Instead of having the skeleton text filling the whole ion-item space, it is compressed in a few pixels space.
I noted that the skeleton text container (ion-text) is not stretching without any text inside.
I've also tried the following without success:
- use a div instead of an ion text
- remove h1 and p
- use any combination of Flex Properties as .ion-align-items-stretch and .ion-align-items-stretch
Here is the structure of my item:
<ion-item class="ion-no-padding" lines="full" detail="true" *ngFor="let num of [0,1,2,3,4,5]">
<ion-thumbnail slot="start">
<ion-skeleton-text animated="true"></ion-skeleton-text>
</ion-thumbnail>
<ion-text>
<h1><ion-skeleton-text animated="true"></ion-skeleton-text></h1>
<p><ion-skeleton-text animated="true"></ion-skeleton-text></p>
<p><ion-skeleton-text animated="true"></ion-skeleton-text></p>
<p><ion-skeleton-text animated="true"></ion-skeleton-text></p>
</ion-text>
</ion-item>
and here what I get:
Thanks in advance,
kind regards.
Beautiful perfect skeleton screen in Ionic
HTML code
<ion-list lines="none" *ngFor="let x of [1,2,3]">
<ion-item>
<ion-skeleton-text width="40%" class="animate-skeleton-background"></ion-skeleton-text>
</ion-item>
<ion-item>
<ion-skeleton-text width="60%" class="animate-skeleton-background"></ion-skeleton-text>
</ion-item>
<ion-item>
<ion-skeleton-text width="100%" class="animate-skeleton-background"></ion-skeleton-text>
</ion-item>
</ion-list>
CSS code
.animate-skeleton-background {
height:20px;
-webkit-animation: infinite bgcolorchange 2s;
animation: 2s infinite bgcolorchange;
opacity: 0.5;
}
#keyframes bgcolorchange {
0% {
color: #f2f2f2;
}
25% {
background: lightgray;
}
50% {
background: #f2f2f2;
}
75% {
background: lightgray;
}
100% {
background-color: #f2f2f2;
}
}
#-webkit-keyframes bgcolorchange {
0% {
background: #f2f2f2;
}
25% {
background: lightgray;
}
50% {
background: #f2f2f2;
}
75% {
background: lightgray;
}
100% {
background: #f2f2f2;
}
}
I figured it out by myself, the idea has been triggered while answering to an answer.
It was as simple as that: just add the following to the scss sheet of the page:
ion-text {
min-width: 100%;
}
I use several menus for my app and I use angular material mat-menu component for this. I can change the style of all menus by writing css code in my global css file for menu original classes. but when I want to add some specific styles to one of them using .custom-class-name .original-material-class-name{} it doesn't apply those styles to that one menu.
here's the whole app in stackblitz: app
header.component.html:
<div>
<a mat-button class="theme-menu-toggle-button" *ngIf="!menuAvailable"
(click)="changeSidenavMode(!mode)">
<mat-icon>menu</mat-icon>
</a>
<a href="#" fxHide.lt-md fxShow.gt-sm class="theme-user" mat-button
[matMenuTriggerFor]="menu">
<img src="assets/images/user.png" class="theme-profile-image rounded-circle">
<span class="theme-profile-title">نام نامخانوادگی</span>
</a>
<mat-menu #menu="matMenu" class="profile-menu">
<button mat-menu-item *ngFor="let option of profileOptions">
<mat-icon>{{option.icon}}</mat-icon>
<span>{{option.title}}</span>
</button>
</mat-menu>
styles.css:
.profile-menu .cdk-overlay-pane::before{
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 15px solid #5E35B1;
content: " ";
position: absolute;
top: 10px !important;
animation: fadeInRightBig 0.75s;
}
Simply set whatever class you want on the mat-menu element.
<mat-menu #menu="matMenu" class="providers-menu" xPosition="after" yPosition="below">
...
</mat-menu>
You can style the menu in your component by using ::ng-deep
::ng-deep .mat-menu-panel.providers-menu {
margin-top: 65px;
background-color: #263358;
}
For more information see this github issue:
https://github.com/angular/components/issues/10322
Add custom class in the mat-menu in backdropClass:
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu" backdropClass="custom__menu">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
.custom__menu + * .cdk-overlay-pane > div.mat-menu-panel > div.mat-menu-content {
background-color: #777;
button.mat-menu-item {
color: white;
}
}
Add your stylings to header.component.css, and import it in your page:
#Component({
selector: 'my-selector',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
UPDATE: You need to add !important tags at end of your css tags.
.profile-menu .cdk-overlay-pane::before{
width: 0 !important;
height: 0 !important;
border-left: 8px solid transparent !important;
border-right: 8px solid transparent !important;
border-bottom: 15px solid #5E35B1 !important;
content: " " !important;
position: absolute !important;
top: 10px !important;
animation: fadeInRightBig 0.75s !important;
}
you should use id for html tag and use it in css file
What do you mean?
I have an ion-item that looks like that:
I would like to place the item-content div more to the left:
Question: What is the correct sass variable to change the values correctly? And how can I achieve that the item-content is aligned the same way in every ion-item independently on the label length?
My code:
<ion-list no-lines>
<ion-item-sliding *ngFor="let event of events">
<ion-item (click)="showEvent(event)">
<ion-label>
<h2>Projekt:</h2>
<h2>Ort:</h2>
<h2>Wetter:</h2>
<h2>Wind:</h2>
<h2>Temperatur:</h2>
</ion-label>
<div item-content>
<h2>{{event.project}}</h2>
<h2>{{event.place}}</h2>
<h2>{{event.weatherMain}}, {{event.averageTemp}}°C</h2>
<h2>{{event.windSpeed}} m/s</h2>
<h2>{{event.averageTemp}}</h2>
</div>
</ion-item>
<ion-item-options>
<button ion-button icon-only color="primary" (click)="deleteEvent(event)">
<ion-icon name="trash"></ion-icon>
</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
CSS:
.scroll-content {
background-color: #ecf0f1;
display: flex !important;
justify-content: center;
}
ion-list {
width: 90%;
}
ion-item-sliding {
margin-top: 20px;
border-radius: 20px;
}
ion-item {
border: none !important;
font-weight: bold !important;
}
You can try changing the following sass variables
$item-md-padding-end, $item-ios-padding-end
They're set to 16px in
/src/themes/ionic.theme.<dark|default>.<ios|md|wp>.scss