What is the process for generating a flexible multi-column unordered list in a single column using Bootstrap 4?

I have been attempting to design a multi-column unordered list that can be centered in relation to its heading. Despite trying various methods found online to create two columns, I have struggled to properly center it under a heading or adjust the padding between the columns of the list. Whenever I manage to achieve the desired aesthetic, typically by using left padding, it compromises responsiveness and ends up looking unattractive. What is the most effective way to create a multi-column list like this?

My goal: Desired Outcome

Current depiction: Current Status

Code and Style Sheet Examples:

  @import url('https://fonts.googleapis.com/css?family=Nunito:400,700,800|Open+Sans:400,700,800');
html,
body {
  height: 100%;
  min-width: 300px;
  margin: 0;
  padding: 0;
  font-family: 'Open Sans', sans-serif !important;
}

.navbar {
  font-family: 'Nunito', sans-serif !important;
}

// More CSS styles...

More HTML...

Answer №1

Place the unordered list in a row-column pair (nesting) and include style="column-count: 2" within it. All set!

In simpler terms, swap out your current list with this code snippet:

<div class="row">
    <div class="col" style="column-count: 2">
        <ul class="Test">
            <li class= "pb-3 puzzle">Puzzles</li>
            <li class= "pb-3 wrench">Handy Work</li>
            <li class= "pb-3 plane ">Travel</li>
            <li class= "pb-3 car">Automobiles</li>
            <li class= "pb-3 volunteer">Volunteering</li>
            <li class= "pb-3 camera">Photography</li>          
        </ul>
    </div>
</div>

The addition of the css rule column-count: 2 will automatically divide the content into two columns.

To demonstrate the functionality, here's a complete solution enclosed in a container (although you may not need an additional container in your case):

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<style>
    /* CSS styling for icons */
</style>

<div class="container">
    <div class="row">
        <div class="col" style="column-count: 2; column-gap: 50px;">
            <ul class="Test list-unstyled">
                <li class= "pb-2 pt-2 puzzle">Puzzles</li>
                <li class= "pb-2 wrench">Handy Work</li>
                <li class= "pb-2 plane">Travel</li>
                <li class= "pb-2 car">Automobiles</li>
                <li class= "pb-2 volunteer">Volunteering</li>
                <li class= "pb-2 camera">Photography</li>
            </ul>
        </div>
    </div>
</div>

By utilizing the list-unstyled class on the ul, bullet points are eliminated.

To fine-tune left alignment of list items, apply classes such as pl-2 or pl-3 to the li elements (or modify margin-left: 8px; in custom css for individual icons). Adjust spacing between icons and text by altering margin-right: 8px; in custom css for each icon. To reposition the second column, adjust column-gap: 50px;.

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

Creating a button inside an input field using HTML and CSS

Is there a way to place a button inside a text input field? I want to achieve this design: https://i.sstatic.net/q2M9v.png This is my current code: input { background: #8196aa; border: 0; border-radius: 10px; color: whi ...

The hidden Material UI Collapse component is still occupying space on the page

Currently, I am implementing Material UI Collapse in my React project and encountering an issue where it is causing unnecessary space on the interface when hidden <Collapse in={false}> //content here </Collapse> Even though I have not a ...

Adding extra space to the list items in CSS causes the text to become static and unaffected by fluctuations in the line-height

Here's the problem I'm facing: I have a basic list consisting of a shopping cart, login and user registration. I want to adjust the position of the list by adding padding, but every time I do so, the line height also increases. Is there a workaro ...

Intersection Observer is functioning properly as elements vanish once they finish appearing

New to this forum and looking forward to receiving assistance and making some fantastic connections! Currently working on my personal portfolio with the goal of getting it online for job hunting purposes, but encountering some challenges along the way. T ...

Manipulate an image with PHP and jQuery to rotate it, then store the edited image in a specified destination directory

This is not just a question, but an opportunity to share knowledge with many like-minded individuals. After spending hours working on rotating images dynamically using PHP and jQuery, I have come up with a solution that I believe will benefit others in the ...

Proportional fluid image grid with responsive design

After implementing various media queries, I've managed to create an image grid using Bootstrap 4+ that looks great on specific devices and layouts. Here's the reference code: .cmd-three-img-container { position: relative; margi ...

Store a designated text into a MySQL database by extracting it from every file within a directory

I've encountered various methods for "crawling" websites, but none seem to fit my requirements. I am interested in being able to extract data from each file within an online directory and then store the extracted information into a MySQL database: h ...

Difficulty altering link hover background color

I'm having trouble changing the hover effect background-color on the tweets of this page: Despite my efforts, all the links except for the latest tweets are working perfectly. What am I missing? Here's what I've been trying... <script& ...

Conceal the scroll bar while still allowing for scrolling functionality

In this code snippet, I am trying to maintain the scroll position of two blocks by syncing them together. Specifically, I want to hide the scrollbar of the left block while scrolling the right one. If anyone has any suggestions or solutions for achieving ...

What is the best way to iterate through a subdirectory using Jekyll?

Currently utilizing Jekyll, I've organized my project with a folder named "articles" at the root. Inside this folder, there are two subfolders: "fr" and "eng". My objective is to loop through the "fr" folder on one page and the "eng" folder on anothe ...

Identify Horizontal Swipe Gestures on Page-level

I am currently focused on ensuring accessibility for users utilizing voiceover technology. While navigating their phone, these individuals rely on right and left swipes to interact with elements on a page. I am seeking to implement swipe detection at the ...

Tips for displaying the Year Dropdown before the Month Dropdown in Jquery Datepicker

Currently utilizing the jQuery UI datepicker. Is there a way to display the Year Dropdown first and the Month Dropdown second in the jQuery Datepicker? I am looking to achieve a layout similar to this: ...

Using image paths in CSS for styling purposes

As I develop an Asp.net website, I've encountered a surprising issue. Here is my folder structure: - Styles - master.css - Images -webPages -scripts When trying to access an image in the Images folder from the CSS file, I receive a ...

I'm having trouble displaying the Facebook page plugin on my HTML website

I encountered a minor issue. I attempted to add the "Facebook page plugin" on a test website. I copied the code from the official Facebook plugin page: <!-- 1. Include the JavaScript SDK on your page once, ideally right after the opening <body> t ...

Issue concerning invisible border

Let's take a look at my simplified CSS code: body { background: url('bg.gif') left top; } #content { background: #ddd; } .box { overflow: hidden; margin-top: 10px; background: #1e1e1e url('left-bottom-corner.gif&ap ...

Is it necessary to utilize container or container-fluid within the grid system layout?

While similar questions may already exist on Stackoverflow, I believe the exact answer has yet to be found. Many suggest: "You should nest .col within .row, and ensure that .row is inside of .container." However, this concept still eludes me. I underst ...

Is it necessary for the input element to be placed within a form?

One of the components I have in my React project has a specific purpose: allowing the user to input a word, press enter or click a link, and go to that word's definition page. 'use client'; import { FontAwesomeIcon } from '@fortawesome ...

Storing a MySQL query result in a global array in a Node.js environment

Just diving into the world of Node.js and Express, I'm trying to wrap my head around asynchronous functions and global variables. Specifically, I'm working on connecting to a MySQL database, fetching query results, and displaying them on a test.h ...

Zoom out the slider when scrolling

Take a look at this link and as you scroll down the page, notice how the image transitions to iPhone. Can anyone provide insight on how this effect is achieved? ...

Displaying Image from Jquery Ajax Response

I have a PHP script that can resize images with specified dimensions by passing the width and height as variables like so: resize.php?width=100&height=200. The content-type of this PHP script is set to image/jpg. Additionally, I have an HTML page wher ...