Separate the array list into 3 columns, however, there seems to be a misalignment issue with the HTML

Need help with dividing a list into 3 rows with Lines separating two columns. This is the code I have written:

HTML
let Arr = [
  { num: 'jkjjk' },
  { num: 'jkjjk' },
  { num: 'jkjjkkj dshdjsh jhsjhsdj' },
  { num: 'jkjjkkj dshdjsh jhsjhsdj' },
  { num: 'jkjjkkj  ' },
  { num: 'jkjjkkj  jhsjhsdj' }
];

{Arr.map((element) => (
  <ul className={divide}>
   <li>{element.num}</li>
  </ul>
)}

<div>

CSS

.divide {
  -webkit-column-count: 3;
  -moz-column-count: 3;
  column-count: 3;
  column-gap: 40px;
  column-rule: 1px solid rgba(0, 0, 0, 0);
}

Although this code works, the alignment of elements in the columns is off. The first column element is on top while the rest are in the middle or bottom of the row. I want to align all elements at the top of each column.

Note: The alignment issue may be due to the length of the string in the elements causing the problem.

Please suggest how I can solve this issue.

Answer №1

Give this a shot:

<ul className="separate">
  {Array.map((item) => (
    <li>{item.number}</li>
  )}
</ul>

CSS Tips

.separate li {
  word-break: break-all;
}

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

Guidelines on how to extract linked text using Selenium in C#

I am attempting to automate the download of files from a lined text, but unfortunately, I am having trouble getting it to work. I am a beginner with selenium. Here is the HTML code of the site: Ttnc-18p - 17.34 GB <table class=&q ...

What is the best way to stop an embedded mp4 video from playing when a dynamically generated button is clicked?

After making modifications to the QuickQuiz code found at https://github.com/UrbanInstitute/quick-quiz, I have replaced the img with an embedded mp4 video that loads from a JSON file. Additionally, I switched from using the original SweetAlert library to S ...

Is there a way to trigger a custom event from a Web Component and then intercept it within a React Functional Component for further processing?

I'm facing an issue with dispatching a custom event called "select-date" from a custom web component date picker to a React functional component. Despite testing, the event doesn't seem to be reaching the intended component as expected. Below is ...

Trigger a function using ng-click and only execute the second function if the condition is met

Currently in the process of validating a form with a function called "myFunction". <button class="btn btn-lg btn-primary btn-block" type="submit" ng-click='form.$valid && myFunction()'>SEND</button> The function should only ...

Locate consecutive characters in an array's string and swap them out

Here is an example array: arr=['Hello World', 'Bye World', 'Useless World'] I am looking to utilize JavaScript to identify consecutive characters that are the same ("ss") and substitute them with an asterisk (*) ...

Implementation of async operations using while loop in Node.js

I'm facing an issue with my code snippet. Here's what it looks like: Rating.find({user: b}, function(err,rating) { var covariance=0; var standardU=0; var standardV=0; while (rating.length>0){ conso ...

Tips for concealing an <li> element when the Button features the text "sometext" using jQuery

I have a table displayed in the image above that I need to hide using jQuery when the button inside it is labeled "ASK". Although I know how to make the table disappear with the code $("div.table").css("display", "none");, I am having trouble relating the ...

The method for implementing conditional CSS on an element and ensuring it remains in place

I'm looking to add a style to an element with either angular or jquery, but I've noticed that the style gets lost when I change views. Would it be best to use $window and local.storage for this purpose, or are there simpler methods available? ...

Encountered a node-pre-gyp installation error while running npm install

As I attempted to follow the React in Action book, I encountered an issue with the project repo - book's project repo Upon running npm install on Ubuntu, I encountered the following error: npm ERR! errno 1 npm ERR! <a href="/cdn-cgi/l/email-prote ...

Enhancing the functionality of radio buttons through event changes and optimizing related features

I am searching for a more efficient method to reuse functions that serve a similar purpose. For example, I would like to modify various radio buttons that toggle a hide class on different divs. JSFiddle Link How can jQuery be used to create a reusable fu ...

Incorporate a Burger Icon into the Navigation Menu

insert image description here I am currently working on implementing a hamburger slide-out feature in my navigation bar. The desired behavior is for the sidebar to slide out to the right. We are using Elementor within WordPress for this project. Has anyone ...

Include JSON information in the middleware request

I have recently started working with express and node, and I am currently working on a task that involves adding JSON data to middleware request. Here is the approach I have devised: Within my middleware, I need to include certain details in the request s ...

Automatically launch a popup window specified in JavaScript

Aim:- I am trying to automatically open a radwindow from the server-side based on a specific IF condition. Snippet Used:- In the aspx page, I have defined the radwindow as follows: <telerik:RadWindowManager Skin="WBDA" ID="AssetPreviewManager" Modal= ...

Express is causing an issue with the AngularJS loading process

When I view the index.html file in a browser, everything works fine. However, when I try to run it on a local server using Express, it doesn't work as expected. Server.js const express = require('express'); const app = express(); app.get ...

Determining the height of a component in React Native

https://i.sstatic.net/VLqIb.jpg The image demonstrates the styling of the component: <TouchableOpacity style={{ height: listDataSource[item.key].isExpanded ? 500 : 140, width: widthw * 0.8, marginHorizontal: 12, backgroundColor: 'red', }} Wh ...

"Enhance your browsing experience with the Safari extension's Context

I've been trying to add a context menu with an icon and 3 additional sub menu items to my Safari extension, but I'm struggling to find a way to do it. Is it even possible to achieve this in Safari extensions? ...

Is there a way for me to limit my usage of the async keyword in my code

Consider the scenario outlined below, using Javascript: Deep within the call stack, Something transforms into a Promise This transformation can occur due to various reasons. // a calls b, calls c, and so on. function z(){ // Let's assume this ...

Proper method for sending functions to handlers in 'simple' components within React

Consider this straightforward example where the prop toggleData is a redux thunk action that is mapped to the container props. Is this the best approach for passing a function like this to a child 'dumb' component? I recently came across an arti ...

Leveraging Python Variables in HTML within a multiline Python string

Attempting to create HTML code using Python and run it from a browser. Check out the code below: import webbrowser f = open('image.html','w') message = """<html> <head></head> <body><img src="URL"></b ...

Tips for using Selenium and Javascript executor to search through the Canvas system?

Is it possible to automate interaction with a 'graph' created on a canvas? I need to be able to click on elements, drag them, and perform other actions like getting text. Can this be achieved with automation using Selenium and JavaScript executor ...