A clever CSS hack for showing multiple UL lists with LI elements in different columns, based on the width of the webpage

On my HTML game website, I feature multiple UL lists at the bottom of each page:

<h2>How to play?</h2>

<ul>
    <li><a href="/en/ws/google">Via Google</a></li>
    <li><a href="/en/ws/apple">Via Apple</a></li>
    <li><a href="/en/ws/facebook">Via Facebook</a></li>
    <li><a href="/en/ws/amazon">Via Amazon</a></li>
    <li><a href="/en/ws/huawei">Via Huawei</a></li>
</ul>

The lists are currently displayed one after another:

https://i.sstatic.net/ik7Ua.png

In certain Wordpress themes, I noticed that the lists are positioned close together when the webpage width allows for it:

https://i.sstatic.net/350UR.png

Is there a CSS tip or trick someone could suggest for achieving this layout?

It's challenging to figure out how Wordpress does it, and searching hasn't yielded helpful results due to common keywords.

UPDATE:

I followed the suggestion (now deleted) from Majicman02 (thank you!) and experimented with Flexbox:

#footer {
    display: flex;
    flex-wrap: wrap;
}
<div id="footer">
    <h2>How to play?</h2>

    <ul>
        <li><a href="/en/ws/google">Via Google</a></li>
        <li><a href="/en/ws/apple">Via Apple</a></li>
        <li><a href="/en/ws/facebook">Via Facebook</a></li>
        <li><a href="/en/ws/amazon">Via Amazon</a></li>
        <li><a href="/en/ws/huawei">Via Huawei</a></li>
    </ul>

    <h2>Mobile game version</h2>

    <ul>
        <li><a href="/en/ws/android">For Android</a></li>
        <li><a href="/en/ws/ios">For iOS</a></li>
    </ul>

    <h2>Where to talk?</h2>

    <ul>
        <li><a href="https://facebook.com/groups/12345/">At Facebook</a></li>
    </ul>

    <h2>Other languages</h2>

    <ul>
        <li><a href="/de/ws">My word game (German)</a></li>
        <li><a href="/ru/ws">My word game (Russian)</a></li>
    </ul>

    <h2>Legal documents</h2>

    <ul>
        <li><a href="/en/ws/tos">Terms of service</a></li>
        <li><a href="/en/ws/privacy">Privacy policy</a></li>
        <li><a href="/de/ws/imprint">Impressum</a></li>
        <li><a href="/de/ws/dsgvo">Datenschutzerkl&auml;rung</a></li>
    </ul>
</div>

The outcome appears favorable as it utilizes the entire webpage width.

Any suggestions on how to ensure the h2 header stays above the ul lists?

https://i.sstatic.net/bLnV4.png

Answer â„–1

After some tinkering, I successfully implemented a multi-columned webpage footer using the flex-wrap property of flexbox.

To ensure that my H2 headers and UL lists stayed intact, I had to enclose them in a DIV element:

#footer {
    display: flex;
    flex-wrap: wrap;
}

#footer > div {
    padding: 8px;
}
<div id="footer">
    <div>
        <h2>How to play?</h2>

        <ul>
            <li><a href="/en/ws/google">Via Google</a></li>
            <li><a href="/en/ws/apple">Via Apple</a></li>
            <li><a href="/en/ws/facebook">Via Facebook</a></li>
            <li><a href="/en/ws/amazon">Via Amazon</a></li>
            <li><a href="/en/ws/huawei">Via Huawei</a></li>
        </ul>
    </div>

    <div>
        <h2>Mobile game version</h2>

        <ul>
            <li><a href="/en/ws/android">For Android</a></li>
            <li><a href="/en/ws/ios">For iOS</a></li>
        </ul>
    </div>

    <div>
        <h2>Where to talk?</h2>

        <ul>
            <li><a href="https://facebook.com/groups/12345/">At Facebook</a></li>
        </ul>
    </div>

    <div>
        <h2>Other languages</h2>

        <ul>
            <li><a href="/de/ws">My word game (German)</a></li>
            <li><a href="/ru/ws">My word game (Russian)</a></li>
        </ul>
    </div>

    <div>
        <h2>Legal documents</h2>

        <ul>
            <li><a href="/en/ws/tos">Terms of service</a></li>
            <li><a href="/en/ws/privacy">Privacy policy</a></li>
            <li><a href="/de/ws/imprint">Impressum</a></li>
            <li><a href="/de/ws/dsgvo">Datenschutzerklärung</a></li>
        </ul>
    </div>
</div>

In addition, I have included some padding around the child DIV elements of #footer. Learn more about child combinator here.

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

I used the `MyWindow=window.open` function to display a pop-up window and then navig

On my webpage (http://localhost:8088/hse/public/explorer), I have implemented two buttons: When these buttons are clicked, a new pop-up window will open at (http://localhost:8088/hse/public/explorer/1) onClick="MyWindow=window.open('http://local ...

Ways to navigate through a webpage without encountering any overflow issues

My window is too small to scroll, but I still need the ability to do so. Is it possible to scroll even when the height of the container is not large enough to display the scrollbar? Below is the code I am using to achieve scrolling: setTimeout(function() ...

Changing the size of a dynamic watermark png in php

I'm trying to automate the resizing of a watermark to cover 1/4 of an image. The code for the watermark is functioning, but I'm facing issues with resizing it correctly. <?php $image = $_GET['src']; $path_parts = pathinfo($image); ...

Seamless movements to the exact midpoint

I am trying to find a method to create a smooth transition when removing the center class from p.title.class, allowing it to smoothly move to its new position. JSfiddle Here is an excerpt of my HTML: <body> <div class="wrapper-top"> ...

Create a visually appealing rectangular box with written content inside

Can you assist with designing a text box similar to this image: https://i.sstatic.net/K5zw8.png I would like the login label inside the border of the textbox. Any guidance on how to achieve this using Bootstrap and CSS would be greatly appreciated, thank ...

Only one specific SVG tag is affected by the CSS stylesheet

I'm encountering an issue with my web page that has multiple SVG tags. Each SVG tag includes a block of style tags containing CSS styles for the respective SVG element. The problem is that these styles seem to leak into the overall global styles. For ...

Having trouble with implementing Jquery for inserting an element and then animating it using CSS through a class change

I am trying to insert an element using the "insertAfter" method and then add a class to trigger a CSS animation. It seems to work when I use a timeout function: First Approach (with Timeout) $content.insertAfter($("#2")); setTimeout(function(){ $con ...

TypeError: 'array' type does not contain the method 'fetch_attribute'

I've encountered an issue with a piece of code that I'm working on and I'm trying to retrieve a link from an element identified as "statistic_info_link". However, when I attempt to do so, I receive the following error message: AttributeErr ...

How can I prevent the content on my page from adding padding to the body of the page?

I'm working on designing a simple interface similar to Slack. However, I'm facing an issue where the left navigation is creating some padding from the body, even though I have set the padding and margin to zero. .app { display: flex; flex- ...

Eliminating bottom section in HTML/CSS

I've got this code snippet: new WOW().init(); /* AUTHOR LINK */ $('.about-me-img img, .authorWindowWrapper').hover(function() { $('.authorWindowWrapper').stop().fadeIn('fast').find('p').addClass('tr ...

What is the best way to implement Arial Narrow using CSS?

#content{ margin-left: auto; margin-right: auto; margin-top: 0; font-family: "Arial Narrow"; position: absolute; font-size: 10pt; } This snippet represents a section of my CSS code that specifies the Arial Narrow font family for the content area. ...

Testing out various Xpaths but none seemed to be effective

I am trying to extract a score from the following URLs: shows a score of "10" displayed in an Octagon image, while has a score of "5". Upon inspecting the elements, I found the score represented as: <text y="100" dy="0.32em">& ...

Navigating into the forbidden territory of the if block that holds secrets untold

Encountering an issue with the angularjs $location feature. I have set up an auth interpreter that redirects to the login page if a 401 error (unauthorised) is returned by the server. In my app.js file, both the auth interpreter and the account data loadin ...

Positioning CSS icons beside text

I'm having trouble aligning a close button I created in CSS with regular text. Although the containing span element seems to align with the adjacent text, it doesn't align properly with the child divs. <a class="event-filter button" href="#"& ...

Is there a way to iterate through indexed variables in javascript?

After receiving an array of data from a JQuery .ajax function, I noticed that the fields in the array are named and numbered like part1, part2, part3, etc. I attempted to loop through this data using the code below, but unfortunately, it resulted in NaN: ...

Modifications to the toolbar styling are made by the Angular Material mat-form-field

Having some trouble creating an input field in my component alongside a mat-toolbar element. When I try to insert a mat-form-field, it ends up messing with the styling of the mat-toolbar. I've been unable to pinpoint exactly where the issue lies (if ...

The table's content extends beyond the confines of the page

I have an HTML page where I am embedding an SSRS report. The report extends beyond the page as shown in the image below: This is the table that is generated: <table cellpadding="0" cellspacing="0" id="ctl00_MainContent_FiveYearReportViewer_fixedTable" ...

Is there a way to upload multiple files using expressjs?

I'm looking for a way to efficiently send multiple files, including an entire directory, so that I can access them in another JavaScript file called from an HTML file. const app = require("express")(); const http = require("http"). ...

Transferring Chart Div Titles Above Bars

Is there a way to adjust the layout of an HTML bar chart so that the names or labels appear outside of the bars, tagged to the left end? <!DOCTYPE html> <style> .chart div { font: 10px Ubuntu; background-color: white; text-align: right; ...

Issue occurs when a circle element is not following a div element on mouse

Currently, I have implemented some jQuery code that instructs a div named small-circle to track my cursor movement. I discovered how to accomplish this by referencing a thread on stack overflow. I made slight modifications to the script to suit my specifi ...