Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6693671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:00:38+00:00 2026-05-26T06:00:38+00:00

I had a look here http://novitskisoftware.com/test/multiplecolumnsEms.html and at various other sites for making a

  • 0

I had a look here http://novitskisoftware.com/test/multiplecolumnsEms.html and at various other sites for making a multi column list and it works fine.

What I wonder is if let’s say I have a dynamic list and if there are for example 10 list items I want to keep eight of them in the first column and the rest in the second, i.e. always 8 items in first columns if there are more than 8 of them.

I assume this is not possible with only CSS/HTML so is it something I can do with JavaScript/jQuery? I prefer to keep the plugin’s to a minimum.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:00:39+00:00Added an answer on May 26, 2026 at 6:00 am

    Suppose the HTML page generated contains:

    <ul>
        <li class="item1">A</li>
        <li class="item2">B</li>
        <li class="item3">C</li>
        <li class="item4">D</li>
        <li class="item5">E</li>
        <li class="item6">F</li>
        <li class="item7">G</li>
        <li class="item8">H</li>
        <li class="item9">I</li>
        <li class="item10">J</li>
        <li class="item11">K</li>
        <li class="item12">L</li>
        <li class="item13">M</li>
        <li class="item14">N</li>
        <li class="item15">O</li>
    </ul>
    

    You may now use JavaScript to generate the required CSS as follows:

    /*
        unorderedList: the HTML ul element
        columnSize:    the number of items per column
        columnGap:     the distance between 2 columns in ems
        offset:        the offset of the first column in ems
    */
    
    function generateMultiColumnLayout(unorderedList, columnSize, columnGap, offset) {
        var items = unorderedList.getElementsByTagName("li");
    
        for (var i = 0, l = items.length; l--; i++) {
            var itemStyle = items[i].style;
            itemStyle.lineHeight = "1.2em";
    
            if (!i && i % columnSize) {                   // old column
                itemStyle.marginLeft = offset + "em";
            } else {                                      // start of new column
                offset += columnGap;
                itemStyle.marginLeft = offset + "em";
                itemStyle.marginTop = -columnSize + "em";
            }
        }
    }
    
    window.onload = function () {
        var items = document.getElementsByClassName("item1");
    
        for (var i = 0, l = items.length; l--; i++) {
            generateMultiColumnLayout(items[i].parent, 8, 10, 5);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had a look at code.google.com, but I didn't find anywhere how to programatically
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
Ok. I recently made some updates to this website. http://annberingerart.com/index.php Upon making some minor
I have created a JSFiddle of my case here: http://jsfiddle.net/gGCaX/ (Please take a look,
I had a look around and didn't find what I was exactly looking for.
I've had a look around on StackOverlow but haven't been able to find a
I've had a look at the metronome sample given by Apple, however, the sample
I've had a look at Stack Overflow question Initialization of a microSD card using
I've recently had to look for a C# porting of the Protocol Buffers library
I've had a look around for the answer to this, but I only seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.