1

I am trying to display images in one row but I want it to be dynamic where if the screen size changes its does not wrap and display them below but instead displaying a button that redirects to another page... Im not sure how to do this

so far , html:

<ion-row align-items-center>
    <ion-col col-auto>
        <img src="assets/images/image.png" />
    </ion-col>
    <ion-col col-auto>
        <img src="assets/images/image.png" />               
    </ion-col>
    <ion-col col-auto>
        <img src="assets/images/image.png" />               
    </ion-col>
    <ion-col col-auto>
        <img src="assets/images/image.png" />               
    </ion-col>
    <ion-col col-auto>
        <img src="assets/images/image.png" />               
    </ion-col>
    <ion-col col-auto>
        <img src="assets/images/image.png" />               
    </ion-col>
</ion-row>

enter image description here

if screen orientation changes/ smaller screen device (not the desired effect):

enter image description here

the desired effect supposed to be like this:

enter image description here

I know that I have to generate the columns in .ts side but not sure where to start and how calculate the screen width size... or maybe there is a better way to do it... any suggestions ,thanx

1
  • 1
    Maybe media queries could be used here. Commented Apr 22, 2017 at 9:56

1 Answer 1

1

First you should add a button to your html:

<ion-row id="myRow" align-items-center style="position: relative; width: 100%; overflow: hidden">
    <ion-col col-auto>
        <img src="assets/images/image.png" />
    </ion-col>
    ...
    <button id="button1" style="display: none; position: absolute; right: 0; top: 0">
       It is your button. It has postion absolute and placed in right top of the row. 
       But it display none now.
    </button>
</ion-row>

In your .ts file, you can check the width of the row and decide show or hide the button:

let row = document.getElementById('myRow');
let width = row.clientWidth;
let button = document.getElementById('button1');
if(width <= xxx){
   button.style.display = "block";
} 

Hope this help :)

Sign up to request clarification or add additional context in comments.

2 Comments

I decided to go with media screen.... but one thing is not quite working, the overflow is not hidden... I loop 10 items , all of them appear
Could you please post your HTML and CSS in a live editor like codepen then i can help you easier?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.