Is it possible to generate a fresh vertical table column when the table length hits a specific point or reaches the bottom of the screen?

I have styled a table element to appear like a vertically aligned list, but I am looking for a way to automatically create a new table column when the existing one reaches a certain length or nears the bottom of the screen. Here is the code I have implemented so far:

<!DOCTYPE html>
<html>
<head>
<style>
table {
  border-collapse: collapse;
  width: max-content;
}

td {
  height: max-content;
  vertical-align: center;
  text-align:center
}
</style>
</head>
<body>

<h2>Test</h2>

<p>This is just a test.</p>

<table>
    <tr><td>Random String Blah</td></tr>
    ... (additional rows)
    <tr><td>Random String Blah</td></tr>
</table>

</body>
</html>

For a visual representation of the desired end result, please refer to this image:

Answer №1

Consider utilizing flex attributes

table {
  border-collapse: collapse;
  width: max-content;
}

table tbody {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 80vh;
}

td {
  height: max-content;
  vertical-align: center;
  text-align:center
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta http-equiv="X-UA-Compatible" content="IE=edge>
    <meta name="viewport" content="width=device-width, initial-scale=1.0>
</head>
  <body>    
    <h2>Test</h2>    
    <p>This is merely a test.</p>    
    <table>
      <tr><td>Random String Blah</td></tr>

<!-- Remaining table rows omitted for brevity -->

    </table>    
  </body>
</html>

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

Storing the options' ids in an array within a select box using JavaScript: tips and tricks

Check out this snippet of HTML code: <select id="s1"> <option value="volvo" id="o1">Volvo</option> <option value="saab" id="o2">Saab</option> <option value="opel" id="o3">Opel</option> <option value="au ...

Bootstrap cards have a fixed width and do not wrap

I've been diving into Django and although I'm fairly new to CSS, I managed to put together a page displaying various products using Bootstrap cards. https://i.sstatic.net/xme5m.png It appears that my code should have wrapped these cards pr ...

Demonstrate how to pass a newline character from Ruby on Rails to JavaScript

I am working with a .js.erb file that is activated by a JavaScript function. Within this js.erb file, I have the following snippet of code: event = <%=raw @event.to_json %> $('#preview-event-body').html(event.body); The value of event.bo ...

Values do not appear as expected post PDF conversion using wkhtmltopdf

Currently, I am updating certain values within my HTML page by following this process: The function: function modifyContent(){ var newTitle = document.getElementById('myTextField1').value; if( newTitle.length==0 ){ alert('Plea ...

Calibrating height using CSS

Within my HTML document, I have the following structure: <div id="content"> <div id="wrapper"> <div id="steps"> <form id="formElem" name="formElem" action="" method="post"> <fieldset class ...

Is there a way to make a TABLE expand to match the height of its surrounding element? (or, tackling sluggishness in IE with JavaScript)

I am facing a challenge with a web page where I have a table nested inside of a TD tag. Despite the unconventional approach, I need to ensure that the height of the nested table matches the height of the TD cell containing it upon page load. Currently, I a ...

The function openModel() in AngularJS is generating an error indicating that it is not a valid function

I am facing an issue with my project that combines AngularJS and Materialize CSS. I am trying to open a modal with id #modal-some-form using AngularJS $('#model-some-form').openModel();. Interestingly, I have another project with similar code, u ...

Show information stored in a database table in an HTML table format using PHP

Within my "enchere" database, there exists a table named Produit. The goal is to exhibit the information stored within the produit table: Nom_produit, description_produit along with the product's image. The image itself is located on a server, in thi ...

Using a function to invoke Highcharts

I am encountering a problem while trying to invoke a function that includes the code for generating a Highcharts chart. The error message I receive is: TypeError: $(...).highcharts is not a function data: (function() { I have double-checked that hig ...

Strange border appears in HTML email table for specific sizes of screens

I am working on an HTML email and encountering a strange issue. When I view the email in Chrome with responsive mode enabled, there is a faint border on some of the cells. I cannot identify the cause as none of the cells have borders, and the issue only ap ...

What is the best way to arrange "divs" in a horizontal orientation?

<div id="MainContent"> <div id="signinContent"></div> <div id="registerContent"></div> </div> I have a main content div with child divs inside. I am looking to align these child divs horizontally. What is the be ...

Tips for calculating the total of each row and column in a table with jQuery

<table id="repair-invoice"> <tr> <th>Item</th> <th>Parts</th> <th>Labor</th> <th>Total</th> </tr> <tr> <td>Oil Change</td&g ...

Obtain the URL of the hyperlink when clicked

After the scenario described above, I am looking to have a user click on a hyperlink and then have it copied into a PHP variable. Is this achievable? I attempted the following but it doesn't seem to be working. Any suggestions? Code: <script ...

How to display or conceal a section of the form depending on the checkbox selection?

I have a pair of checkboxes labeled First and Second <input type="checkbox" name="checkbox1" id="checkbox1" value="checkbox1" /> First <br /> <input type="checkbox" name="checkbox2" id="checkbox2" value="checkbox2" /> Second Additiona ...

Issue with Materialize Sidenav: Not functional on iOS devices including iPhones, functions correctly on all other devices

My Materialize Sidenav is functioning on all devices except for iPad and iPhone. If you want to check out the code, here is the link to the repository: repo. Take a look at index.html (line 44 down) and js/onloadSetup.js. I attempted adding this in onload ...

Freemarker substitute & and &ampersand;

I am facing an issue with Freemarker. I need to eliminate all the special characters from this sentence as well as from similar sentences in the future: BLA BLA RANDOM &, RANDOM BLA In particular, I want to remove the & character. The platform ...

Strategies for choosing the perfect GIF to showcase in a React JS project

Hey everyone, I'm completely new to working with react JS and I've encountered a problem. I have a task where I need to display GIFs when a button is clicked, but I'm struggling to select a specific GIF. Can anyone provide some guidance on f ...

What are the steps to create a dynamic grid interface using Bootstrap 5?

I attempted to use the code below but it did not work: <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/> <div class="container-fluid"> <div class="row"> <div c ...

I'm struggling to determine the source of the color for my linked CSS. Any ideas where to look?

I am experiencing an issue with a link that is displaying as white and gray for "a" and "a:hover", despite my CSS file specifying otherwise. Firebug confirms this, but I can't figure out what is overriding it. Can anyone offer any insight? Below is t ...

The third @media query for max-width is not functioning as expected in the CSS

Looking to create a responsive card section on my website for various screen sizes. The goal is to display 5 cards per row when the screen width is greater than 1300px, maintain 3 cards per row from 1024px to 1300px, and then switch to only 2 cards per row ...