The scrolling feature within individual div elements seems to be malfunctioning in Ionic 2

In my current project using Ionic 2, I am faced with the task of designing a screen that contains two distinct grid views.

The first grid view needs to occupy 40% of the height, allowing for scrolling within that specified area.

On the other hand, the second grid view should be continuously scrollable without a fixed height, adjusting based on the content size:

< ion-content >

<div>
Contents of the first grid view
</div>

<div>
Contents of the second grid view
</div>

</ion-content>

Initially, neither <ion-content> was scrolling as intended. When I attempted to set specific heights for both grid divs, they no longer scrolled at all. Here is a snippet of my code:

Complete code example:

<ion-content class="no-scroll" style="width: 100%;overflow-y: hidden;">

// Code for the first grid starts here
<div class="item item-body no-padding" scrollY="true" style="border-width: 0px !important;height: 42%;">  
  <!-- Grid view elements begin below -->
<div class="row no-padding"  *ngFor="let data of ResourceDetailData; let i = index">
     <ng-container *ngIf="i % 2 === 0">

          <div class="col col-50 custom-design2" style="background: url() no-repeat center;background-size: cover;">
               <div class="custom-design1"><span class="grid-title">{{ResourceDetailData[i].categoryname}}</span></div>
            </div>

            <div class="col col-50 custom-design2" style="background: url() no-repeat center;background-size: cover;">
                 <div class="custom-design1"><span class="grid-title">{{ResourceDetailData[i+1].categoryname}}</span></div>
             </div>
     </ng-container>


</div> 
</div> 

<!-- End of first grid view code -->

// Code for the second grid view

  <div class="item item-body no-padding" scrollY="true" style="border-width: 0px !important;">  
  <!-- Grid view elements begin below -->
<div class="row no-padding"  *ngFor="let data of ResourceDetailData; let i = index">
     <ng-container *ngIf="i % 2 === 0">

          <div class="col col-50 custom-design2" style="background: url(url) no-repeat center;background-size: cover;">
               <div class="custom-design1"><span class="grid-title">{{ResourceDetailData[i].categoryname}}</span></div>
            </div>

            <div class="col col-50 custom-design2" style="background: url() no-repeat center;background-size: cover;">
                 <div class="custom-design1"><span class="grid-title">{{ResourceDetailData[i+1].categoryname}}</span></div>
             </div>
     </ng-container>


</div> 
</div>

</ion-content >

Answer №1

It seems like there may be some confusion with the scenario, but one option is to utilize an ion-scroll for the initial grid. By doing this, you can allocate 40% of the page height to this scroll, leaving the remaining space for the other grid.

I would recommend checking out this example plunker to see how it could work:

https://i.sstatic.net/P5HNn.gif

<ion-header>
  <ion-navbar>
    <ion-title>Ionic Demo</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>

  <ion-scroll style="width:100%;height:40%;" scrollY="true">

    <!-- First grid -->

  </ion-scroll>

  <!-- Second grid -->

</ion-content>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a Stylish Web Design with Bootstrap HTML - Tips for Perfecting Your Output

My code is producing the following output: But I want to achieve this instead: How can I modify my code to get the desired layout? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email_ ...

Utilizing Typescript for directive implementation with isolated scope function bindings

I am currently developing a web application using AngularJS and TypeScript for the first time. The challenge I am facing involves a directive that is supposed to trigger a function passed through its isolate scope. In my application, I have a controller r ...

AngularJS has separated the $http service into its own distinct file for easier organization

I am facing an issue with separating the $http GET request for a dictionary from the controller into a separate file as a service. I have searched for solutions, but haven't come across any suitable hints. Please provide me with some guidance. Below ...

Strategies for adjusting text size to fit within a resizable div container

I'm facing an issue with a resizable div that has text inside. When I resize the div, the last line of the text goes beyond the boundaries of the div. How can I ensure that all the text fits within the resizable div while maintaining the appropriate f ...

How can I prevent users from clicking the same link multiple times in HTML?

Is it possible to disable the href after one click using javascript or jquery? I need some assistance with this. Please help. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml ...

The cursor remains positioned below the video within the designated div

I'm currently facing an issue in a project where the cursor div I created stays underneath the video element. No matter what I do, I can't seem to bring it to the front. Even setting a z-index on the video tag hasn't helped. Can someone plea ...

Variety of background colors for different categories

Is there a way to showcase my categories with different background colors using a custom post type? I want to link the slug name from my taxonomy to serve as the class attribute for a span element and style it with CSS. However, I am encountering issues wi ...

Do you want your image to appear visually pleasing on all screen sizes?

Currently, I am working on a mobile website and encountering an issue with the image banner. For tablets, it should look like this: However, when viewed on mobile, it needs to appear as follows: This is the code I have implemented so far: <div class ...

When it comes to AngularJS, the concept of undefined or null

Whenever I write watch handling functions, I always make sure to check the newVal parameter for both undefined and null. It makes me wonder why AngularJS doesn't have a specific utility method for this purpose. For example, there is angular.isUndefine ...

New method for obliterating a controller with the usage of the as and this structure

Is there a different approach to destroy a controller when using the 'as' syntax and binding values on the controller, or should I still rely on the scope? For example, if a controller is declared in the dom using the 'as' syntax: < ...

Ways to update the background hue of a selected Navigation Tab?

One of the challenges I am facing in my React Project is with the Navigation Tab from material-ui. The issue I encounter is that the active tab should have a background color, and then revert to its original color when not active. However, the transparency ...

What is the best way to connect a directive's attribute to a dropdown menu in Angular.js?

Within a dropdown, I have a selection of templates that are connected to $scope.templates: [{"id":1, "name":"Test 1",{"id":2, "name":"Test 2"}]. Furthermore, there is a directive in place, <editor data-template="1"></editor> The goal is to ...

How to retrieve the optgroup label from a Bootstrap Select dropdown

Currently, I am working with a BootStrap select box and my goal is to identify the optgroup of the option that has been selected. The following code snippet showcases a bootstrap select box with different options: <li rel="1"> <div class="div- ...

Getting the values of $scope variables from AngularJS in the controller to the view

I have a simple scope variable on my AngularJS Controller. It is assigned a specific endpoint value like this: $scope.isItAvailable = endpoint.IS_IT_AVAILABLE; How can I properly use it in my view (HTML) to conditionally show or hide an element using ng- ...

When developing a website with HTML/CSS, is it recommended to utilize tables for organizing content

Seeking guidance as a novice in web development. I am planning to design a table with input fields that will be sent to the server upon submission. What is the preferred method for achieving this? Is it advisable to utilize html-tables or would it be more ...

Chrome/IE displaying text indentation issue within nested divs

Encountering issues with nested divs in Chrome and IE, while Firefox works smoothly. The outer div has both text-indent and margin-top styles set. The inner div's display style is block, so the content after it should appear on a new line without any ...

What is the best way to incorporate a personalized HTML closing button into the body of a jQuery Dialog box?

Related Inquiry: How to incorporate custom buttons with ids into a dialog-modal jQuery object I'm wondering if anyone can help me figure out how to close my jQuery Dialog using a custom button that I've added to the .html body. Should I change t ...

The size of the website elements needs to be increased for better visibility on mobile devices

While developing the official website for my Discord bot - Idle Baker, I opted to utilize Bootstrap 5 for its user-friendly design features, making it easier than dealing with extensive CSS coding. After completing the homepage of the site, I encountered ...

Surprising Results when Using getBoundingClientRect()

Check out this code on CodePen In my current project, I'm attempting to position the footer div at the bottom of the page in such a way that it aligns with the maximum value of the bottom coordinates of both the menu and content divs (Math.max(menu, ...

The issue of the JQuery div failing to center itself persists even after refreshing the page

I have implemented a script to centrally align the main content div within the viewing area. It works perfectly on page load or resize, but upon page refresh, the content div shifts to the left side of the page. You can see the issue here when pressing re ...