Populate an HTML table with information arranged by column

I have a dataset that needs to be presented in a grid format that adjusts based on the size of the screen.

The data is arranged alphabetically, and I prefer to showcase it column by column for better readability:

|---------|--------|--------|
| Abi     | Donald | George |
| Boris   | Ernest | Harold |
| Charlie | Frank  | Ivan   |

When viewed on a wider desktop viewport, it might appear like this:

|-------|---------|--------|--------|------|
| Abi   | Charlie | Ernest | George | Ivan |
| Boris | Donald  | Frank  | Harold |      |

Since the table is responsive, the number of columns (and subsequently rows) could vary. While Twitter Bootstrap makes it easy to achieve responsiveness using .col-md-3, I want my table to populate vertically, by column.

Is there a way to accomplish this only with CSS without resorting to reordering and calculating with Javascript?

Answer №1

Here is a simple way to achieve this using Bootstrap:

<div class="myItems col-lg-3 col-md-3 col-sm-6 col-xs-12">
    <ul>
        <li>Apple</li> 
        <li>Banana<li> 
        <li>Cherry</li>
    </ul>
</div>

If you prefer the opposite layout, you can try:

<div class="myItems col-lg-12 col-md-6 col-sm-3 col-xs-6">
    <ul>
        <li>Apple</li> 
        <li>Banana<li> 
        <li>Cherry</li>
    </ul>
</div>

Don't forget to add the following styles in your CSS:

.myItems ul{display:block;}
.myItems li{display:inline-block;}

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

Is there a way to get rid of the tiny black line beside the Instagram icon?

Here is the display on my website This is the code that was used I am struggling to identify the source of the small black "-" line next to the Instagram icon logo. ...

creating nested columns within a parent column using flexbox techniques

Struggling with column height issues in Bootstrap 3? Consider using flexboxes for a simpler solution. Check out the design image I created using Bootstrap 3: https://i.sstatic.net/PVCKm.png Can this design be replicated with flexboxes? I have successfull ...

Is it achievable to use PHP to automatically scroll to the bottom of a container?

Is there a way to automatically scroll to the bottom of a div container using PHP code instead of javascript or CSS? While I haven't been able to find a solution using just CSS, I have come across some options utilizing javascript. However, since I a ...

Place CSS elements in relation to the underlying element

This is an example of my HTML structure: <nav id="menu"> <ul> <li><a href="">Products</a></li> <li><a href="">Offers</a></li> <li><a href="">References</a>& ...

Setting the height of a webpage element to match the height of the window through CSS

How can I make the .Bck div stretch to the full height of the browser window? I attempted using jQuery, but the height doesn't adjust correctly when I resize the window. What is wrong with my JavaScript and can this be achieved with CSS alone? <!- ...

Combining Images with Jquery: A guide to layering multiple images on top of each other

In this code snippet, I have a webpage that allows users to customize their own shirt. By selecting options such as "Male/Female," the '#shirt' section dynamically displays an image of the constructed shirt by layering PNG images on top of each o ...

Is there a way to have these slides repeat automatically?

After spend some time working on this, I've hit a roadblock. I managed to create a div slider with navigation arrows where each slide has a minimum width of 80px. The code functions correctly, except that when I reach the last item and try to naviga ...

Struggling with creating a fluid/elastic/liquid layout in HTML. Can someone please assist me with this

I've been attempting to incorporate a fluid layout on my friend's website, but unfortunately, it doesn't seem to be functioning properly. The page is quite simple, with just a slider on it. Could you please take a look at it and let me know ...

Unique style pattern for parent links with both nested and non-nested elements

I am in the process of designing a website and I have a specific vision for how I want my links to appear, but I am unsure of how to achieve it. Here is the desired outcome: a red link a green link a red link a green link … Below is the HTM ...

Customize the appearance of disabled dates in the eonasdan-datetimepicker styling

I am seeking to customize the default styles for the "eonasdan-datetimepicker" (https://github.com/Eonasdan/bootstrap-datetimepicker) by implementing a basic hover message feature. The CSS attributes currently applied to disabled dates are as follows: .bo ...

Ensure that the table is padded while keeping the cells collapsed

I am currently working on creating a table with borders between each row. However, I am facing an issue where the row borders are touching the outer border of the table. Despite my efforts, I have been unable to find a solution to this problem. I feel like ...

Using Bootstrap 4 to split lengthy text into multiple columns, similar to how it is done in Microsoft Word

Is there a way in Bootstrap4 to create MS Word-like multicolumn text flow? For example, in Word we have: https://i.sstatic.net/buCXu.png In Bootstrap4, the code below will generate a two-column grid: Example: <div class="row"> <div ...

Create a CSS dropdown menu design similar to the one shown in the image

I am seeking guidance on how to replicate the design depicted in this image: https://i.sstatic.net/Hl8HZ.jpg Currently, my menu structure is as follows: body { background: white; margin: 0; padding: 0; } /* / nav */ nav { width: 100%; backgr ...

Make individual term span the entire width of 100%

Is it feasible to expand a single word like "News" to occupy 100% width of the div element? My goal is to automatically adjust letter spacing and justify individual words. Currently, I have a menu with items such as: Home About News Etc It would be idea ...

Setting the second tab as the primary active tab

I am currently working on a script that is well-known, and everything is functioning perfectly. However, I want to change it so that when the page is first opened, it displays the second tab instead of the first one (the first tab being a mail compose tab ...

What could be causing the last LI to drop onto a new line when floating UL to the right?

I'm currently working on creating a horizontal navigation that needs to align to the right side of the page. However, when I float the navigation to the right and then float all the list items to the left, the last item in the list breaks onto a new l ...

What is the best way to horizontally center a div that has position:absolute within a table

Hello there, I am attempting to align a div in the center of a td element. I have set the position of the td as relative and the div as absolute. Is there a way to center the div without changing its absolute positioning? ...

Experiencing problems with various React Carousel libraries when it comes to displaying

I have been attempting to integrate Carousel libraries into my react app, but I am encountering a common issue with all of them. The Carousels show the items on the first slide, but subsequent slides do not display any items, even though they exist within ...

mobile screens causing bootstrap columns to overlap

The code I am working with is shown below: <div class="container"> <div class="col-md-3 calendar"> </div> <div class="col-md-9"> <button></button> (more buttons...) </div> < ...

As I spun four images along the outer edge of a circular border, one image came to a halt at 90 degrees, revealing its content. Now, I am looking to enlarge that particular

I managed to rotate four images around a circular border and stop one image at every 45-degree angle. However, I am struggling to enlarge the image that stops at 90 degrees on the website while still showing the content of the respective image when it reac ...