Maintaining consistent height among various lists with varying item lengths

In order to display multiple lists side by side, I have two main objectives:

  1. I want the scroll to be synchronized across these lists. This means that when I view an item in one list, I should easily be able to see the corresponding item in the other lists. Achieving this synchronization should be straightforward if I can address the second goal successfully.
  2. I need to ensure that each row in all the lists has the same height. For example: if the second element in all the lists is a phrase and it fits in one row in the first list but three rows in the second list, I want to make sure that even in the first list the space allocated for that item is three rows tall. This will facilitate sync scrolling and comparison of values.

The structure of my lists is quite simple, as shown below:

<div class="container">
  <h3>
    Conflicted Version Item
  </h3>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
  <h6>Bla bla bla</h6>
</div>

//css

.container{
  max-width: 25vw;
  min-width: 18vw;
  padding: .75rem;
  margin-bottom: 2rem;
  border: 0;
  flex-basis: 33.333%;
  flex-grow: 0;
  flex-shrink: 0;
  overflow-y: scroll;
  max-height: 90%;
}

Here is how the list container should look:

<div class="conflicted-versions">
    <app-conflicted-version-item></app-conflicted-version-item>
    <app-conflicted-version-item></app-conflicted-version-item>
    <app-conflicted-version-item></app-conflicted-version-item>
    ...
  </div>

//css
.conflicted-versions{
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: 30vh;
  }

Note that app-conflicted-version-item represents the list described in the first code snippet.

I am seeking recommendations to tackle the second challenge, as I believe I can handle the first one once the second issue is resolved.

Answer №1

Here's a better way to structure the elements:

<Col class="mega-list">
  <Row class="field1">
    <Col>list1.field1</Col>
    <Col>list2.field1</Col>
  </Row>
  <Row class="field2">
    <Col>list1.field2</Col>
    <Col>list2.field2</Col>
  </Row>
</Col>

This organization ensures that the rows will adjust their height based on the content with the longest length.

(You can use divs with flex-direction: row or column for Rows and Cols, respectively)

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

Enhance Prime-ng dropdown child elements with customized styling

Currently, I am attempting to apply styles to elements within a PrimeNG dropdown. These particular styles are associated with child elements nested within the p-dropdown tag, and I am unsure of the proper method to target them. Below is a snippet of the co ...

Angular Flot Chart Resizing: A Guide to Dynamic Chart S

I have successfully integrated a Flot chart into my HTML using an Angular directive. Here is how it looks: <flot id="placeholder" dataset="dataset" options="options" height="300px" width="100%" style="width:100%;" ng-disabled="graphLoading" ng-class="{ ...

What is the best way to extract a URL parameter from the parent page and pass it to an iframe using JavaScript?

Currently, I have embedded a form within an iframe on a specific landing page. Visitors arriving at this landing page through an affiliate link will have a parameter added to the URL (http:thelandingpage.com?c3=1). After they submit the form within the ifr ...

Displaying a loading image when opening an external link using window.open

When a pop-up is opened through a window.open() function for external sites, I am looking to display a loading image icon for the links. One approach I considered is to show the loading image in a 'div' and retrieve the content of the external s ...

When I tried using the HTML 5 boilerplate extension in VS code, I received an error message indicating that it was not functioning properly

I've recently entered the realm of tech and decided to give VS Code a try. After downloading it, I installed several extensions, but unfortunately some of them aren't functioning properly. My primary issue is with the HTML5 boilerplate extension. ...

Generate a refined selection of options for a secondary dropdown menu sourced from a database

There are two dropdown lists in my project. One is dynamically populated based on user selections, while the other is filled with data from a database. The second list should be filtered according to the choice made in the first dropdown. The values in th ...

Is there a more efficient way to optimize my coding for this Cellular Automata project?

As a beginner in programming, I wanted to delve into the world of cellular automata and decided to create my own using JavaScript. The project involves a simple binary (black and white) 2D CA where each cell updates its color based on the colors of its 8 ...

Issue with Angular and CharJS: TypeError occurs when trying to read property '15' of an undefined value

An error message was encountered as follows: ERROR TypeError: Cannot read property '15' of undefined at ChartElement.getPixelForValue (Chart.js:14599) at ChartElement.updateElement (Chart.js:5930) at ChartElement.addElementAndReset (Chart.js:3781 ...

Retrieving information from a service for use in MatTableDataSource

I'm currently working on populating MatTableDataSource with data obtained from CustomService. Below is the code for my component: @Component({ selector: 'app-dashboard', templateUrl: './dashboard.component.html', styleUrls: ...

Is there a way to modify the browser's user agent using JavaScript or HTML?

I currently have an application that is running on IE7. However, an analytics tool I rely on has recently been updated and now requires a minimum of IE8. Is there a way to modify the User Agent in IE7 using JavaScript or HTML to trick it into being recogni ...

Reimagining scrolling through content with a stylish unordered list (a sleek alternative to a select box

After having our company website redesigned by a professional designer, our site now looks much more visually appealing. However, I have encountered difficulties when trying to implement their design using HTML and CSS. One particular challenge is the heav ...

Issues with Thunderbird not displaying copied HTML emails

Hello there amazing people at Stackoverflow. I need some assistance with HTML formatting. I am currently working on a bootstrap modal that is being dynamically modified through jQuery using the append() function. Check out the code snippet below: <div ...

Exploring all the options within a dropdown menu using JQuery

Within the MVC 4 view, there is a dropdown box that, when its value changes, needs to capture all selected values. Each selection consists of three items: the Id, the visible value on the form, and a path to a file. While the functionality works for readin ...

Tips for generating an interactive collapse effect with the simple click of a button

Does anyone know how to implement a collapsible feature when a button is clicked? I would appreciate some assistance. Essentially, the goal is to extract data from the screen when the "Add" button is clicked, and then display it in a collapsible format. ...

Is it possible to have separate click functions for the onclick attribute and jQuery click handler on an anchor tag, instead of just calling one function through onclick?

Attempting to implement multiple click handlers for an anchor tag: one using the "Onclick" attribute handler and the other using a jQuery click handler. This excerpt is from my HTML file. <html> <head> <script src="http://code.jquery.com ...

What is the best way to emphasize parent categories in a product table using Woocommerce?

I have a table of products used for filtering categories. My goal is to display only the parent categories in bold font. When searching results like in this link (e.g. https://demo.motorocker.gr/?swoof=1&antalaktika=scooter), we want the parent categor ...

What is the process for eliminating the message "Hello Member" on the Woocommerce Checkout page?

I've been struggling to remove a certain area on the checkout page without success. I attempted using this CSS code: .avada-myaccount-user-column .username { display:none; } https://i.stack.imgur.com/okFg9.png https://i.stack.imgur.com/GisRQ.png Cu ...

Import JSON Data into Angular-nvD3 Chart (AngularJS)

I am seeking help to load encoded JSON Data retrieved from a database via queries into an Angular-nvD3 graph. I am unsure about the best approach to achieve this task. The encoded JSON data is fetched using API queries from a database table called PRODUCT ...

displaying and concealing elements with jquery

Is there a way to hide a div if the screen size exceeds 700px, and only show it when the screen size is less than 700px? Below is the jQuery code I'm attempting to use: jQuery(document).ready(function() { if ((screen.width>701)) { $(" ...

"Learn how to retrieve the chosen option from a select input and set it as the value of the ng

Here is a select menu that I have: <div class="medium-3 columns"> <label>First Menu <select name="first-menu"> <option *ngFor="let i of items" [value]="i.name">{{i.name}}</option> </select&g ...