Converting nested lists into Miller Columns: a step-by-step guide

I am interested in creating a series of interactive nested lists using Miller Columns design. The idea is that when you click on a parent item, it expands to reveal the next level of the list.

While I have come across solutions that involve parsing data as JSON, I am looking for a way to achieve this effect using plain HTML without needing to convert the data format.

The structure of my content is based on a standard nested list format:

<ul>
<li><a href="">Column 1</a></li>
<li><a href="">Column 1</a></li>
<li><a href="">Column 1</a></li>
<li><a href="">Column 1</a>
    <ul>
    <li><a href="">Column 2</a>
        <ul>
        <li><a href="">Column 3</a>
        <ul>
        <li><a href="">Column 4</a></li>
        <li><a href="">Column 4</a></li>
        <li><a href="">Column 4</a></li>
        <li><a href="">Column 4</a>

        </li>
        </ul>
        </li>
        <li><a href="">Column 3</a></li>
        <li><a href="">Column 3</a></li>
        <li><a href="">Column 3</a>

        </li>
        </ul>
    </li>
    <li><a href="">Column 2</a></li>
    <li><a href="">Column 2</a></li>
    <li><a href="">Column 2</a></li>
    </ul>
</li>
</ul>

I would appreciate any guidance on how to accomplish this task without relying on JSON parsing methods. Thank you.

Answer №1

Using Miller Columns to Display Columns

Check out the Fiddle here.

You can achieve this effect with some simple CSS solutions. If you prefer CSS over SASS, there are online converters available or I can provide the CSS code for you.

ul {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
  display: inline-block; }
ul > li > ul {
  position: absolute;
  top: 0;
  left: 100%;
  padding-left: 10px; }

This approach uses the current column as a reference point for aligning subsequent columns to the right of their parent.

UPDATE

I have removed unnecessary properties like white-space and text-overflow from the solution.

Creating Interactive Miller Columns

UPDATED: PART TWO

Here's the updated fiddle with interactions.

In addition to CSS styling, I have included a jQuery script to handle column interactions. Some visual enhancements have been added for better illustration.

Additional CSS styles:

ul > li {
 background-color: #075883; }

ul > li a {
  color: white;
  padding: 5px;
  display: block;
  text-decoration: none; }

ul > li.expanded > ul {
  overflow: visible;
  max-width: 500px;
  transition: 0.2s; }

Here's the jQuery code (which can also be implemented in pure JavaScript):

$('li a').on('click', function() {
  $(this).parent().toggleClass('expanded').siblings().removeClass('expanded'); 
});

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

FlexNav excluding

I have implemented FlexNav for my website navigation. The demo I used sets the width of top-level menu items to 20%, which works well with five menu items. .flexnav li { . . . width: 20%; } However, in my menu, the text lengths of the top ...

Using a custom attribute in jQuery allows conditional statements to be executed using the

I have been attempting to create an if/else statement in jQuery using a custom attribute called "data-id". I decided to name it this way because I thought I could utilize the .data() method in jQuery, but unfortunately, it did not work as expected. Below ...

Showing the value of a JavaScript variable within an HTML input field

Here is an interesting HTML structure that includes a list and input field: <li> <span>19</span> </li> <li> <span>20</span> </li> ...

Navigate through the Div and Unordered List with ease by scrolling

What is the reason behind the scrolling behavior of div with arrow keys while ul does not exhibit the same response? This issue is connected to a previous question that I have posted, but has not received any responses yet. ...

I am having trouble styling a pre-existing class in bootstrap using my custom CSS file

html <section id="title"> <div class="container-fluid"> <!-- Nav Bar --> <nav class="navbar navbar-expand-lg navbar-dark"> <a class=" navbar-brand">tindog</a> ...

Tips on automating the process of moving overflowing elements into a dropdown menu

Challenge Description In need of a dynamic navigation bar, I faced the problem of displaying only the first X items on one line and have the remaining items hidden in a "Show more" dropdown. The challenge was to calculate the width of each item accurately ...

Error in Flask app: Stripe Elements - "400 bad request: CSRF token not found or invalid"

Currently, I am in the process of following the Stripe Quickstart guide for integrating stripe Elements with Flask. While working through the tutorial available at https://stripe.com/docs/stripe-js/elements/quickstart, I encountered an issue - the token ap ...

Interactions with Ajax through the use of socket.io communications

1)I'm working on creating an online quiz using socket.io to listen to nodes. To retrieve questions and answers from a database with php, I need to implement ajax. In my app.js (node js server file), I am generating a random number and emitting it to t ...

Utilizing JavaScript to dynamically set a CSS file from an API in AngularJS

I am currently facing an issue with integrating a CSS file returned by an API into my entire website. Since the URL of the CSS file keeps changing, hard coding the URL is not feasible. While I have successfully implemented this on 'view1', my goa ...

Color schemes for items in the Windows store app

I'm having trouble changing the background color of an item in my split application. I've tried using CSS, but nothing seems to work. Here is the template for the item (default style): <div class="itemtemplate" data-win-control="WinJS.Bindin ...

Choose an image to be displayed at either full width or full height, depending on which dimension is reached first

I have a query regarding resizing an image within a div to either 100% width or 100% height of the containing div. Despite setting max-height and max-width to 100% as recommended here, I still encounter overflow issues without wanting to crop the image usi ...

Creating a minigame using JQuery (Javascript)

I am currently developing a collection of mini-games for my big project. The approach I've taken in creating this mini-game is similar to one I used previously. However, unlike my previous version which only had one PuzzleContainer, this new iteration ...

Title: How to Build a Dynamic Logo Carousel with React and CSS without External Dependencies

Currently, I am in the process of integrating a logo carousel into my React web application using CSS. My goal is to create a slider that loops infinitely, with the last logo seamlessly transitioning to the first logo and continuing this cycle indefinitely ...

Stylish CSS menu that adjusts to different screen sizes, featuring a centrally aligned h1

I am trying to center an h1 element in my navigation, alongside two other elements, without using an image. I want it to be responsive as well. I have attempted various methods but have had limited success, as most solutions require the use of background i ...

An engaging CSS3 animation that alternates between popping in and out, resetting after each item has been displayed

My project involves using a background image in the form of a map. I am looking to display a series of testimonials as absolutely positioned divs on this map, and have them appear and disappear one after another. Once all testimonials have been shown, I ne ...

Creating a div that is subtly askew

When it comes to positioning a div 15 pixels off-center horizontally from the page, traditional methods like setting margins to auto or using position:absolute may not work in this situation. The challenge lies in ensuring that the div scales correctly a ...

Designing a uniquely shaped button

Is there a way to design a button with a slightly irregular shape? The current CSS for my button creates a basic rectangle like this: .btnclass { width:100; height:40; } However, I would like it to have a more unique appearance such as this: ...

Tips for incorporating jQuery UI into Angular 6

No matter how many methods I have tried from StackOverflow, I cannot seem to get jquery-ui to work in my angular 6 component. Here's what I've attempted: I went ahead and ran npm install jquery jquery-ui to install both jquery and jquery-ui. ...

What is the best way to toggle the readonly attribute on an input within an ng-repeat row when a button is clicked?

Here is some HTML content: <!---- HTML Content ----> <div class="container-fluid" ng-app="myApp"><br> <div class="row" ng-controller="mainController"> <div class="col-md-12"> <div class="panel pa ...

Use JavaScript to convert only the initial letter to uppercase

Once again, I am in the process of learning! Apologies for the simple questions, but learning is key... Attempting to implement a trick I found online to change all letters to uppercase, I am now trying to adjust it to only capitalize the first letters. T ...