Ionic grid trouble - ionic-framework

<ion-grid>
<ion-row wrap style="background-color: #25dfc3">
<ion-col>
<ion-slides pager>
<ion-slide>
<h1>Slide 1</h1>
</ion-slide>
<ion-slide>
<h1>Slide 2</h1>
</ion-slide>
<ion-slide>
<h1>Slide 3</h1>
</ion-slide>
<ion-slide>
<h1>Slide 4</h1>
</ion-slide>
</ion-slides>
</ion-col>
</ion-row>
<ion-row style="background-color: #ffffff;">
<ion-col>Amethyst!</ion-col>
</ion-row>
</ion-grid>
Is there any way to make my first row bigger than the second? I've been watching many tutorials but it seems that the flexbox solutions doesn't help me.

Actually you can just add a height in the first row.
<ion-grid>
<ion-row wrap style="background-color: #25dfc3; height: 300px;">
<ion-col>
<ion-slides pager>
<ion-slide>
<h1>Slide 1</h1>
</ion-slide>
<ion-slide>
<h1>Slide 2</h1>
</ion-slide>
<ion-slide>
<h1>Slide 3</h1>
</ion-slide>
<ion-slide>
<h1>Slide 4</h1>
</ion-slide>
</ion-slides>
</ion-col>
</ion-row>
<ion-row style="background-color: #ffffff;">
<ion-col>Amethyst!</ion-col>
</ion-row>
</ion-grid>
View it here:
https://stackblitz.com/edit/ionic-rhdvzq

i have solved the issue with flex like so:
<ion-grid>
<ion-row class="top">
<ion-col>
<ion-slides pager>
<ion-slide>
<div class="sprite">
</div>
</ion-slide>
<ion-slide>
<h1>Slide 2</h1>
</ion-slide>
<ion-slide>
<h1>Slide 3</h1>
</ion-slide>
<ion-slide>
<h1>Slide 4</h1>
</ion-slide>
</ion-slides>
</ion-col>
</ion-row>
<ion-row style="background-color: #ffffff;">
<ion-col col-1></ion-col>
<ion-col col-10>
<button ion-button block (click)="login()" >Inicia sesión con Facebook</button>
<p></p>
<button ion-button block color="secondary" (click)="pushPage()" >Accesa con tu teléfono</button>
<p></p>
Términos y condiciones
</ion-col>
<ion-col col-1></ion-col>
</ion-row>
</ion-grid>
login-tutorial{
.top {
flex: 4;
background-color: #e8343b;
}
.button-block{
margin-top: 14px;
}
a {
text-align: center;
font-size: .7em;
float: left;
margin-left: 30%;
margin-top: 18%;
}
h1 {
color: #fbb034;
}
.swiper-pagination-bullet-active {
background: #fbb034;
opacity: 1;
}
.sprite {
width: 47.25px;
height: 51px;
/*margin-left: 42%;*/
margin: auto;
background-image: url("../../assets/imgs/babyL.png");
animation: luigui 1s steps(11, end) infinite;
}
#keyframes luigui {
from {
background-position: 0px;
}
to{
background-position: -549.25px;
}
}
}
screenshot 1
Then I copied the same code to another app, however, the result is different. It seem like the flex is not working...
screenshot 2

Related

hw to resize image ionic framework in grid view

I ve got this code, i want to reset images dimensions with css , any help ?
<ion-content class="categories">
<ion-row>
<ion-col size='6' size-sm="4" size-md="3" *ngFor="let category of data.mainCategories" (click)="getProducts(category.id)">
<ion-card class="category-card" class="ion-activatable ion-focusable hydrated" mode="md">
<ion-img alt="" src="{{category.image?.src}}"></ion-img>
<ion-card-header>
<ion-card-title [innerHTML]="category.name"></ion-card-title>
</ion-card-header>
</ion-card>
</ion-col>
</ion-row>
</ion-content>
I tried
ion-img {
object-fit: resize;
height: 20px;
width: 20px;
border: 0;
padding: 0;
}

Ionic3 slider flip effect not working

Please check code below, I want to flip my slides but this won't getting applied.I am new in Ionic and trying hard to get it resolve but no effects getting applied.
<ion-slides pager #mainslider [effect]=flip>
<ion-slide>
<h1>Slide 1</h1>
</ion-slide>
<ion-slide>
<h1>Slide 2</h1>
</ion-slide>
<ion-slide>
<h1>Slide 3</h1>
</ion-slide>
<button type="submit" ion-button color="primary" class="btnNext" (click)="next()">Next holiday</button>
<button type="submit" ion-button color="primary" class="btnNext" (click)="prev()">Next holiday</button>
</ion-slides>
next() {
this.slides.slideNext();
}
prev() {
this.slides.slidePrev();
}
ionViewWillEnter() {
this.slides.onlyExternal = true;
this.slides.effect = 'flip';
this.slides.paginationType = 'fraction';
this.slides.pager = false;
}
You should use effect property like this effect="flip"
<ion-slides pager #mainslider effect="flip">
<ion-slide style="background-color: aquamarine">
<h1>Slide 1</h1>
</ion-slide>
<ion-slide style="background-color:lightblue;">
<h1>Slide 2</h1>
</ion-slide>
<ion-slide style="background-color:darkcyan;">
<h1>Slide 3</h1>
</ion-slide>
</ion-slides>

Ionic 3, ion-col content has to align middle

I have a tabular design from which two ion-col in a ion-row have different number of lines. but I need to align both the content in the middle. what would be best solution for this?
<ion-content padding>
<ion-grid>
<ion-row>
....other cols....
<ion-col col-6>
<label>Date of Audit:
<h2>01/30/18<br/>
1:06:50<small>PM UTC</small></h2>
</label>
</ion-col>
<ion-col col-6 text-center center class="overall-score">
<label>Overall Score:
<h1>40%</h1>
</label>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
The style need to be applied to the ion-col, in order to center its content.
CSS:
ion-col {
text-align: center;
}
or
HTML:
<ion-col class="someclass">
CSS:
ion-col.someclass {
text-align: center;
}
add ion-row
<ion-col>
<ion-row style="min-height:100%" justify-content-center align-items-center>
<p>test</p>
</ion-row>
</ion-col>
Create a new css class:
.align-text-middle {
display: flex;
align-items: center;
}
And add that class to the ion-col.
Use Grids, rows and cols for good practices, read the Ionic documentation, simple and effective.
For center with this:
<ion-grid>
<ion-row justify-content-center>
<h1>This is center</h1>
</ion-row>
</ion-grid>

How to fit ion-slides and button in the same page in ionic 3

<ion-content >
<ion-slides loop #Slides>
<ion-slide >
<h2>Slide 1</h2>
</ion-slide>
<ion-slide >
<h2>Slide 2</h2>
</ion-slide>
<ion-slide >
<h2>Slide 3</h2>
</ion-slide>
</ion-slides>
<button ion-button full>login</button>
</ion-content>
When I use the code above, I have to scroll down to see the button.
Is there any way to force all the components to be on the same page ?
Add this to your page SCSS:
.scroll-content {
display: flex;
flex-direction: column;
ion-slides {
display: flex;
}
}

Ionic 2 horitzonal scroll with ion items

I'm trying to create a list of avatars, and each avatar to appear in the right of the previous avatar. When an avatar reaches the end of the screen, the user will be able to scroll left or right to see more avatars.
I achieved this with the following code which worked in the previous ionic grid version, and now no longer works and when an avatar reaches the end of the screen, a new line is created instead of keep added to the same line with an option to scroll horitzonally:
<ion-scroll scrollX="true" class="chooseBg" style="height:70px">
<ion-row>
<ion-col *ngFor="let avatar of avatars"
style="padding-right:0">
<ion-item>
<ion-avatar>
<img
[src]="avatarImage(avatar)"/>
</ion-avatar>
</ion-item>
</ion-col>
</ion-row>
</ion-scroll>
Any ideas how I can create hortizonal scroll of items using latest ionic grid system? (Ionic 2.2)
This is my Horizontal Scroll with clickable Cards in it:
<ion-scroll scrollX="true" class="item" style="width:100vw;height:100%;margin:0px;padding:0px;">
<ion-row>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Rap")'>
<img style="width:33vw;" src="assets/img/rap.png"/>
<div text-wrap class="card-title-mini">Rap</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Singing")'>
<img style="width:33vw;" src="assets/img/sing.png"/>
<div text-wrap class="card-title-mini">Singing</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Skateboard")'>
<img style="width:33vw;" src="assets/img/skateboarding.png"/>
<div text-wrap class="card-title-mini">Skateboard</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Workout")'>
<img style="width:33vw;" src="assets/img/workout.png"/>
<div text-wrap class="card-title-mini">Workout</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Drawing Tattoo")'>
<img style="width:33vw;" src="assets/img/drawingtattoo.png"/>
<div text-wrap class="card-title-mini">Drawing Tattoo</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Shuffle")'>
<img style="width:33vw;" src="assets/img/shuffle.png"/>
<div text-wrap class="card-title-mini">Shuffle</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Gaming")'>
<img style="width:33vw;" src="assets/img/gaming.png"/>
<div text-wrap class="card-title-mini">Gaming</div>
</ion-card>
</ion-col>
<ion-col >
<ion-card tabable class="card-width" (click)='categorieDetail("Beatbox")'>
<img style="width:33vw;" src="assets/img/beatbox.png"/>
<div text-wrap class="card-title-mini">Beatbox</div>
</ion-card>
</ion-col>
</ion-row>
</ion-scroll>
Well its hardcoded but you can fill it like you do with *ngFor as well.
this is my css:
ion-card {
position: relative;
text-align: center;
margin: 0;
}
.column-width {
width: 100px;
}
.card-width {
width: 33vw;
padding: 0px !important;
margin: 0px !important;
background-color : transparent;
color : transparent;
height: 33vw;
}
.card-title-mini {
position: absolute;
top: 45%;
font-size: 5vw;
width: 100%;
color: #fff;
font-weight: bold;
}
This scroll works on all devices and browsers.
Maybe my scroll might be helpfull for you.