What is the best way to ensure a div is always scrollable?

I am currently working with Angular 4 and Bootstrap 4 (alpha 6). I have implemented ngx-infinte-scroll to fetch data from the server when the user scrolls to the top or bottom of the div. The issue I am facing is that the user can only scroll when there are enough items to display. I want to enable scrolling at all times. How can I make sure that the vertical scroll bar is always visible? The content that needs to be scrollable is within the item-scroller class.

<div class="col-md-9 chat-column">
  <div class="card h-100">
    <div class="card-block item-body">
      <h4 class="card-title center">Test</h4>
      <hr/>
      <div class="item-scroll"
           infinite-scroll
           [infiniteScrollDistance]="0.99"
           [infiniteScrollUpDistance]="0.075"
           [infiniteScrollThrottle]="10"
           [scrollWindow]="false"
           (scrolled)="onScrolledDown()"
           (scrolledUp)="onScrolledUp()"
      >
        <div *ngFor="let i of is">
          {{i}}
        <div class="answer left">
          <div class="avatar">
            <img [src]="i.imageURL" alt="">
          </div>
          <div class="name">{{i.name}}</div>
          <div class="text">
            {{i.text}}
          </div>
          <div class="when">{{i.when}}</div>
        </div>
      </div>
    </div>
  </div>
</div>
</div>

css

.item-scroll {
  /*overflow: scroll;*/
  overflow-y: scroll;
  flex:none;
}

.item-body {
  font-family: "Raleway", sans-serif;
}

Attempts to Solve the Issue

1)

.item-scroll {
  height: 101%
  overflow-y: scroll;
  flex:none;
}

.item-body {
  font-family: "Raleway", sans-serif;
}

2)

.item-scroll {
  height: 101%;
  overflow-y: scroll;
  flex:none;
}

.item-body {
  height: 100%;
  font-family: "Raleway", sans-serif;
}

3)

.item-scroll {
  height: 100%;
  margin-bottom: 0 0 0 1px;
  overflow-y: scroll;
  flex:none;
}

.item-body {
  font-family: "Raleway", sans-serif;
}

Answer №1

Ensure your styles are arranged correctly and consider using 100vh instead of percentages. Take a look at this example:

.wrapper {
    height: 100vh;
    padding: 0;
}

.scroll-content {
    display: block;
    height: 100%;
    width: 100%;
}

In my current project, I am utilizing angular2-virtual-scroll which follows a similar structure in the code.

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

Provide the scope to the directive when calling the $uibModal.open method

I am interested in developing a custom directive that displays data based on the scope of its parent controller. Here is the directive's JavaScript code: (function () { 'use strict'; angular .module('blabla') ...

Creating MySQL inserts from various dynamic HTML tables generated using PHP

Currently, I am faced with a challenge while working on a PHP file that produces multiple dynamic HTML tables through the use of an included PHP library. To provide a glimpse, here is a snippet of the HTML output (with just two tables and reduced rows) ava ...

Ways to turn off JavaScript when reaching a certain breakpoint, similar to a media query

I am facing an issue with my <header> and <nav> blocks which are impacted by JavaScript. Is there a way to create a JavaScript solution similar to a media query that would deactivate this JavaScript code if the window width is less than or equa ...

Fetching Date and Time from the Internet using PHP

While I understand that similar questions have been asked numerous times before, I have yet to find a solution that fits my specific needs. My question is regarding how to retrieve the current date and time from the internet rather than relying on the loc ...

Issues with Stylesheet Rendering in Firefox

Take a look at this Kendo UI Dojo example: https://i.sstatic.net/lVfNM.png When rendered in Firefox, the "right" should also be placed in the header, but it's not. It works correctly in IE11 and Chrome. What am I doing wrong? ...

Passing images to Angular components

Just diving into Angular and tasked with a small project for school. I've got a node backend that sends images via base64 to my angular service... imageService.getUserImagesFromDB(id, (result) => { f ...

Simple way to extract the values from every input element within a specific <tr> tag using JQuery

Is there a way to align all input elements in a single row within my form? For example, consider the snippet of code provided below, which includes a checkbox and a text input box. I would like to retrieve the values from both of these input types and pres ...

angular proxy configuration malfunctioning

I'm struggling to figure out where my mistake is. Despite trying the solution provided in an answer, the issue persists. Here are a few related threads I've explored: Angular-CLI proxy to backend doesn't work Configure Angular-cli proxy f ...

Retrieve the mfData value from the TypeScript file in order to perform operations on it within the Angular 2 framework

I have a snippet of code that iterates through data from stacklist_table, which is a JSON array, and displays it in a table format. The stacklist_table contains a full list of objects, but I only need a subset of these objects so I have applied some filter ...

What is the process for transferring data processed in Python to Node.js and then forwarding it to Angular?

I am a newcomer to Angular and I'm looking for a way to showcase JSON data from Python in my Angular app using Node.js. I have already utilized child processes to establish the connection between Python and Node.js, but I am facing a challenge on how ...

Guide on generating a video thumbnail using JavaScript Application

Searching for a way to easily create a thumbnail from a video for uploading alongside the video itself to a server? I've been looking for JavaScript libraries to simplify the process without much luck. The scenario involves the user selecting a video ...

The program encountered an error: Unable to locate the module 'chart.js' in the directory '/node_modules/ng2-charts/fesm2015'

Having trouble with this error message: ERROR in ./node_modules/ng2-charts/fesm2015/ng2-charts.js Module not found: Error: Can't resolve 'chart.js' in /node_modules/ng2-charts/fesm2015' I ran the command "npm install --save ng2-chart ...

Is there a way to horizontally align the content in my footer section?

I am currently exploring React Material UI for the first time. The table I am working with can be found here under the "Custom pagination actions" section. Within this section, there is footer content containing buttons for rows per page, next, previous, ...

Even though my form allows submission of invalid data, my validation process remains effective and accurate

Here is the code I have written: <!doctype html> <html lang="en"> <head> <title>Testing form input</title> <style type="text/css></style> <script type="text/javascript" src="validation.js"></script> &l ...

Enhancing the appearance of jQuery datatables using Material Design Lite theme

I came across a helpful codepen demo demonstrating how to create a responsive data table with search filter and pagination. However, this demo is only integrated with Bootstrap. After searching the MDL discussion forum, I couldn't find any existing im ...

What is the purpose of the .Class method in ng.core.component within ES5?

ng.core.Component({ selector:'myapp', template:'<h1>Hello World</h1>' }). Class( { constructor:function() } ); ...

Is there a way to implement an extra placeholder attribute with Angular4?

Currently, in a project where I am utilizing Angular Material, there is a form integrated with an autocomplete component. The functionality works as expected but I am interested in implementing placeholder text once the user focuses on the input element. ...

A guide on displaying an Angular Component within a Thymeleaf page

Currently, I am faced with the task of integrating Angular and Thymeleaf. This is necessary because I have developed a dynamic graph using Angular and now need to incorporate it into an existing project that utilizes Thymeleaf. Are there any simplified m ...

Designing Tables for User Interfaces

In a table with 4 rows, the first row must always be filled by the user. The remaining rows are optional. What is the best way to visually indicate this requirement? This should be achieved using only HTML, CSS, and jQuery. ...

Getting the search bar's result set and simultaneously wiping out the existing data

If we input the value 5, a result set is displayed if there is a match. However, entering 56 results in an error message stating "no data found". The issue arises when clearing the first value 6, causing the function to no longer search for the input 5. ...