Creating HTML dynamic lists that remain fixed to the bottom of the viewport, regardless of any changes in their content

I want to create a dynamic list that displays like this -

  <div class="list-wrapper">
    <ul class="list">
      <li class="list-item"> ... </li>
      <li class="list-item"> ... </li>
      ...
      <li class="list-item"> ... </li>
    </ul>
  </div>

The number of list items will vary as new items are added.

The requirement is for the list to stay anchored to the bottom of the viewport, even with new items being added.

  • This means the list should not start at the top and scroll down using JS/TS; it needs to render from the bottom up.

Is there a way to achieve this using only layout / CSS, or do we need to implement something in JS/TS to auto-scroll to the latest item?

Please advise -- thank you!

Before anyone mentions -- that solution is not suitable due to accessibility (a11y) reasons; it's vital for the source order to match the reading order of the page.

Answer №1

If the solution provided in the linked answer aligns with your goal, you may find a helpful tip on avoiding the need to reverse the content.

Does this approach meet your needs?

.list-wrapper {
  position: fixed;
  bottom: 0;
  display: flex;
  flex-direction: column-reverse;
  width: 50%;
  height: 4em;
  overflow: auto;
  border: 1px dashed;
}

.list-wrapper ul {
  margin: 0;
  padding: 0;
}

.list-wrapper li:nth-of-type(even) {
  background-color: silver;
}
<div class="list-wrapper">
  <ul>
    <li> One </li>
    <li> Two </li>
    <li> Three </li>
    <li> Four </li>
    <li> Five </li>
    <li> Six </li>
    <li> Seven </li>
    <li> Eight </li>
    <li> Nine </li>
    <li> Ten </li>
  </ul>
</div>

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

Tips for creating CSS from the Google Chrome inspector for future use

Hey there, I spent the evening debugging my JSF page and noticed some changes in appearance when checking/unchecking options in Google Chrome Inspector. I want to create a new CSS file based on these checked options and save it for use in my web applicat ...

Removing selected options from multiple select boxes in AngularJS using ng-repeat

When using ng-repeat to load multiple select dropdown elements, each dropdown contains the same set of values. However, when a user selects an option from one select box, that option should not appear in any of the other select boxes. For example, if a us ...

Is there a way to transfer PHP user information (session) to a Node.js server?

Currently, I have two separate pages set up for my website. One is the Chat page, which operates on Node.js and Socket.io using WebSockets. The other is the main page where users login and access various features. I am looking to implement a system where, ...

Achieving alignment of items within nested Grid components in React Material UI

Currently, I am working on building a web page using the React Material UI Grid component. However, I'm encountering an issue with aligning items across nested grids. The current view looks like this: https://i.sstatic.net/bUreX.png What I want is fo ...

Best practices for integrating text and images within a website header using CSS and HTML

I need help figuring out the most efficient method for creating a page header that showcases an image while keeping the text visible for search engines and in case the image fails to load. According to Google, it is recommended to use a <div> for th ...

Utilize React Link to redirect to a proxied backend server

One interesting feature of my React App is that it proxies requests to the backend using "proxy": "http://localhost:3001" This setup can be found inside package.json for development purposes. An odd issue has arisen where, when utilizing a React Router ...

The table does not move up or down when using the mousewheel over the rows, but only when

I'm encountering an issue with a table inside a div that has overflow-y: scroll applied to it. While the scrollbar appears when there is content overflow, I am unable to scroll using the scrollwheel. It only works when the cursor is directly on top o ...

Animate the Collade object's position gradually in ThreeJS

In my ThreeJS project, I am working with the elf example from ThreeJS Instead of simply rotating the object as shown in the example, I want to move it in both the x and y directions. To achieve this, I plan on updating the elf.position.x and elf.position. ...

What is the best way to link function calls together dynamically using RXJS?

I am seeking a way to store the result of an initial request and then retrieve that stored value for subsequent requests. Currently, I am utilizing promises and chaining them to achieve this functionality. While my current solution works fine, I am interes ...

Struggling with implementing the group by feature in AngularJS?

Currently, I am trying to group a select-window by 2 different object arrays - subcategories and rootcategories. Each subcategory has a relation id that links to the rootcategory's id. My goal is to have the dropdown window group the subcategories bas ...

Designing a mobile user interface for time intervals

Currently, I am utilizing a datetimepicker for inputting a duration of time within a form. While the UI functions smoothly on a desktop, it struggles in a mobile setting. Despite my efforts, I have yet to discover a suitable alternative that seamlessly ope ...

Show only the results that have identifiers matching the parameter in the URL

My goal is to filter objects based on a URL parameter gatewayId and display only those whose id matches the parameter. import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; @Component({ selector ...

Press the vertical navigation bar

My website is currently undergoing a major overhaul. I am looking to enhance its functionality, but I may have taken on more than I can handle. You can find the link related to my query here: On my top menu, there is a button located on the left side. It ...

There seems to be an issue with Affix functionality in Bootstrap 4 (alpha version)

As detailed in the Bootstrap 3 documentation, I have included the following attributes in a navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Unfortunately, when scrolling down the page with Boots ...

Challenges arise when dealing with an excessive amount of nested POJO structures

What can I do with complex POJOs tree in my template? For example: <div important-attr="{{item.another_sub_item_three.lets_go_a_little_dipper.property}} " another-important-attr="{{ item.another_sub_item_three.just_one_more.ano ...

In vue.js, when utilizing the select all method for checkboxes, it is important to ensure that disabled checkboxes are not

I am working on a project where I have a table containing a list of checkboxes. When I click on the select all function, it selects all checkboxes including the disabled ones. However, I need to exclude the disabled checkboxes from being selected. ...

CAUTION: cleaning unsecure style value background-color

Incorporating Angular, I am retrieving data from Firebase to enable user chat messages to display in a color chosen by the user, specifically using item.color. However, encountering an issue where for a user who selects blue as their color, a warning messa ...

Combining two sets of x-data within a single div

Currently, I am exploring AlpineJS alongside HTML. While it is quite straightforward to hide/show a single div, I am encountering difficulties when trying to toggle the visibility of two elements within the same container. I believe there is a simple solut ...

Typescript library available as a private npm dependency

I have developed a Typescript library that I bundle as an npm module. During the development of my frontend application, I easily integrated this library using yarn link. As I set up GitLab CI for other developers to work on the frontend application, I am ...

Troubleshooting a Pulumi script in Azure using Typescript and encountering difficulties with function writing

My background is in using terraform, but now I am trying out Pulumi/typescript for the first time. In my codebase, I have two files - index.ts and blob.ts. The create function in blob.ts is responsible for creating a storage account, resource group, blob ...