Have list item take all the height - css

I have a page which simply looks like this:
<ion-navbar *navbar>
<ion-title>My List</ion-title>
</ion-navbar>
<ion-content class="has-header">
<ion-list>
<ion-item *ngFor="#item of items">
<ion-toolbar>
<ion-buttons end>
<button>Something</button>
</ion-buttons>
</ion-toolbar>
<img [src]="slide.image" class="slide-image"/>
<h2 class="slide-title" [innerHTML]="slide.title"></h2>
<p [innerHTML]="slide.description"></p>
</ion-item>
</ion-list>
</ion-content>
Let says there are 100 items. I would like each item to take the full height. So you should not be able to see the next or previous item at all unless you scroll. I would like the height of every item to be the same which would be the size of ion-content I guess. How can I do this? I have tried playing around with height, min-height, positioning, flex, but have not been able to make it work?

You can use vh units in modern browsers. Support is pretty good.
ion-content {background: #f6f6b2;}
ion-content + ion-content {background: #b3f4b3;}
ion-content {display: block; height: 100vh;}
<ion-content class="has-header">
<ion-list>
<ion-item *ngFor="#item of items">
<ion-toolbar>
<ion-buttons end>
<button>Something</button>
</ion-buttons>
</ion-toolbar>
<img [src]="slide.image" class="slide-image"/>
<h2 class="slide-title" [innerHTML]="slide.title"></h2>
<p [innerHTML]="slide.description"></p>
</ion-item>
</ion-list>
</ion-content>
<ion-content class="has-header">
<ion-list>
<ion-item *ngFor="#item of items">
<ion-toolbar>
<ion-buttons end>
<button>Something</button>
</ion-buttons>
</ion-toolbar>
<img [src]="slide.image" class="slide-image"/>
<h2 class="slide-title" [innerHTML]="slide.title"></h2>
<p [innerHTML]="slide.description"></p>
</ion-item>
</ion-list>
</ion-content>

Related

Ionic how to align ion-content to bottom of page

I'm trying to align a message input box to the bottom of the page, but I can't seem to get it working. I've tried using align-self-end and making a css class for ion-footer.
<ion-content>
<ion-footer align-self-end>
<ion-toolbar color="light">
<ion-row align-self-end>
<ion-col size="10">
<ion-textarea auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
</ion-col>
<ion-col size="2">
<ion-button expand="block" fill="clear" color="primary" [disabled]="message === ''" class="msg-btn"
(click)="sendMessage()">
<ion-icon name="paper-plane"></ion-icon>
</ion-button>
</ion-col>
</ion-row>
</ion-toolbar>
</ion-footer>
</ion-content>
ion-footer{
display: flex;
align-items: flex-end;
margin: auto;
padding-top: .5em;
padding-bottom: .5em;
}
<ion-footer> is not meant to go inside <ion-content>
The structure of html file should be
<ion-header>
</ion-header>
<ion-content>
</ion-content>
<ion-footer>
</ion-footer>
In your case you want to show another element towards the bottom of the content, you can insert textarea like this..Do not put ion-row inside the ion-toolbar.
<ion-content>
</ion-content>
<ion-footer>
<ion-toolbar>
<ion-textarea maxRows="4" [(ngModel)]="message" placeholder="Write a message"></ion-textarea>
<ion-icon name="paper-plane" slot="end"></ion-icon>
</ion-toolbar>
</ion-footer>
another method would be
.support{
margin: auto;
position: absolute;
text-align: center;
bottom: 20px;
width: 100%;
}
<ion-content padding>
... other elements
<div class="support">
<p>some text</p>
</div>
</ion-content>

Have ion-card on top of ion-slide - Ionic 5

how to make the ion card float on the ion slider with mobile content, when i move the content it scrolls up with everything.
<ion-slide>
<ion-row >
<div>
<ion-card mode="md">
<ion-item class="select-paciente" lines="none">
<ion-button size="default" slot="star">
<ion-icon slot="icon-only" name="arrow-back-outline"></ion-icon>
</ion-button>
<h6 style="color: #073f15;">SERVICE</h6>
<ion-button size="default" slot="end">
<ion-icon slot="icon-only" name="arrow-forward-outline"></ion-icon>
</ion-button>
</ion-item>
</ion-card>
</div>
</ion-row>
<ion-row id="Services">
<ion-col size-lg="1" size-md="2" size-sm="3" size-xs="4">
<ion-card mode="md">
<img src="../../../assets/img.jpg" />
<p>Service1</p>
</ion-card>
</ion-col>
</ion-row> </ion-slide>

Position down all the scroll in ionic 3

I'm creating a chat and my problem is that the div that has the messages inside it I put a scroll, but I can not keep it under everything.
This is the view code and styles:
<ion-grid>
<ion-row>
<ion-col col-12>
<button ion-button block color="success" style="text-transform: none" (click)="seeMembers()">See members</button>
</ion-col>
<ion-col col-12 class="div_chat" #div_theme>
<ion-list insert>
<button ion-item>
<p>test</p>
<p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p>
</button>
</ion-list>
<h3 *ngIf="themeDB == false" text-center><strong>There are no new Topics</strong></h3>
</ion-col>
</ion-row>
</ion-grid>
This is my stylesheet
page-see-theme{
.div_chat{
width: 100%;
height: 300px;
overflow-y: auto;
}
}
Any idea is very useful, thanks for your help

Splitting Ionic card in half. I want to show students on the right and the teachers on the left

This is what I currently have: https://gyazo.com/7b0c0d53beef6846545bece011332cd5 . You can see that I have a lot of pictures next to each other, but I want to have 2 halves in the ionic card. On the topleft the groupname , bottom left the teachers and on the right side the studens in the group. I want it like this: https://gyazo.com/d5e71aa9cfe6de9f121ce236f951a6d7 .
HTML
<ion-header>
<ion-navbar color ="primary">
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>{{ appName }}</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-grid>
<ion-row>
<ion-col *ngFor="let group of groupData">
<ion-card >
<ion-item>
<h2>{{ group.name }}</h2>
<div class="pic" *ngFor="let student of group.students">
<img [src]="student.avatar" />
</div>
<h3>{{group.students.length}} Leerlingen</h3>
<div class="pic" *ngFor="let teacher of group.teachers">
<img [src]="teacher.avatar" />
</div>
<h3>{{group.teachers.length}} leerkrachten</h3>
</ion-item>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
CSS
.pic{
display: inline-block;
height: 40px;
width: 40px;
}
Instead of using ion-item, you can use div tag and set specifically half width of the content like so
<ion-content>
<ion-grid>
<ion-row>
<ion-col *ngFor="let group of groupData">
<ion-card >
<div class="left-content">
<div class="pic" *ngFor="let teacher of group.teachers">
<img [src]="teacher.avatar" />
</div>
<h3>{{group.teachers.length}} leerkrachten</h3>
</div>
<div class="right-content">
<h2>{{ group.name }}</h2>
<div class="pic" *ngFor="let student of group.students">
<img [src]="student.avatar" />
</div>
<h3>{{group.students.length}} Leerlingen</h3>
</div>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
Css
.left-content {
width: 50%;
float: 'left'
}
.right-content {
width: 50%,
float: 'right'
}
Use the grid system
<ion-card >
<ion-item>
<h2>{{ group.name }}</h2>
<ion-row>
<ion-col col-6>
<div class="pic" *ngFor="let student of group.students">
<img [src]="student.avatar" />
</div>
<h3>{{group.students.length}} Leerlingen</h3>
</ion-col>
<ion-col col-6>
<div class="pic" *ngFor="let teacher of group.teachers">
<img [src]="teacher.avatar" />
</div>
<h3>{{group.teachers.length}} leerkrachten</h3>
</ion-col>
<ion-row>
</ion-item>
</ion-card>
Try this new modification if it fits
<ion-card >
<ion-item>
<ion-row>
<ion-col col-6>
<ion-row> <h2>{{ group.name }}</h2></ion-row>
<ion-row>
<div class="pic" *ngFor="let student of group.students">
<img [src]="student.avatar" />
</div>
</ion-row>
<ion-row>
<h3>{{group.students.length}} Leerlingen</h3>
</ion-row>
</ion-col>
<ion-col col-6>
<ion-row>
<div class="pic" *ngFor="let teacher of group.teachers">
<img [src]="teacher.avatar" />
</div>
</ion-row>
<ion-row>
<h3>{{group.teachers.length}} leerkrachten</h3>
</ion-row>
</ion-col>
</ion-row>
</ion-item>
</ion-card>

Add fixed ion-row in top of the ion-content ionic 2

In ionic we can add ion-navbar and ion-toolbar in ion-header but I want to ad some customized menu bar to my application in top of the ion-content for that I add ion row and add z-index and position CSS for that it works in browser but when it build that menu-bar change position it is not fixed in top. I guess that after I fixed the position user cannot scroll the ion-content when scrolling the position of the menu is changes. How can I add customize menu bar to the top of ion-content
this image shows the menu bar in gray color
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-grid>
<ion-row style="position: fixed;height: 50px;background: #444444">
<button ion-button small>test btn</button>
</ion-row>
<ion-row *ngFor="let item of data" style="background: #eee;border: 1px solid #888;height: 40px">
{{item.name}} - {{item.id}}
</ion-row>
</ion-grid>
</ion-content>
you can add a ion-toolbar inside the ion-content tag just like you would in the header and it will work the same, you just need to add a position:fixed to the toolbar
<ion-toolbar style="position:fixed;">
<ion-buttons start>
<button ion-button icon-only color="royal">
<ion-icon name="search"></ion-icon>
</button>
</ion-buttons>
<ion-title>Send To...</ion-title>
<ion-buttons end>
<button ion-button icon-only color="royal">
<ion-icon name="person-add"></ion-icon>
</button>
</ion-buttons>
</ion-toolbar>
I think you need this:
<ion-header>
<ion-navbar>
<ion-title>title</ion-title>
</ion-navbar>
<ion-grid style="position: fixed; height: 50px; background: #444444">
<ion-row>
<ion-col>
</ion-col>
</ion-row>
</ion-grid>
</ion-header>
<ion-content style="top: 50px;">
</ion-content>

Resources