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 6348783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:29:22+00:00 2026-05-24T21:29:22+00:00

I generated a list of <UL><LI> ‘s in PHP. The script generates this from

  • 0

I generated a list of <UL><LI>‘s in PHP. The script generates this from top to bottom:

<ul class="list_test">
<li>111
</li>
<li>222
</li>
<li>333
</li>
<li>444
</li>
<li>555
</li>
<li>666
</li>
<li>777
</li>
<li>888
</li>
<li>999
</li>
<li>1010
</li>
</ul>

Right now they are rendered like this:

111
222
333
444
555
666
777
888
999
1010

How can I combine these in groups?

Let’s say, I would like for example for them to be rendered as:

111 555 999
222 666 1010
333 777 etc
444 888

How can I do this?

I would like to use only Javascript and not modify the PHP. I thought about adding a div for example, 100 px high, that would wrap on the right…

jsfiddle: http://jsfiddle.net/hf2PL/

  • 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-24T21:29:24+00:00Added an answer on May 24, 2026 at 9:29 pm

    I’ve mocked up a solution here: http://jsfiddle.net/eqvc4/

    It uses absolute positioning to re-arrange the <li> elements into columns.
    The JavaScript code is as follows:

    var $ul = $('ul'),
        $li = $ul.children(),
        cols = 3,
        rows = Math.ceil($li.length / cols),
        height = rows * 1.2,
        width = cols * 5;
    
    $ul.css({ height: height+'em', width: width+'em' });
    $li.each(function(index) {
        var col = Math.floor(index / rows),
            row = index % rows,
            left = col * 5,
            top = row * 1.2;
    
        $(this).css({ left: left+'em', top: top+'em' });
    });
    

    It also requires the following CSS:

    ul {
        position: relative
    }
    
    li {
        width: 5em;
        height: 1.2em;
        position: absolute;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this masonry generated list which originally comes from a mysql database. When
I have a list of dynamically generated div-tags with a class-attribute but no id.
I have a situation where the second select list option is generated from the
I have a table list of products generated in PHP. The list contains: title
I have a dynamically generated list of URL's from our internal network. For each
How can I create an array of items from a generated list using a
I have a long list generated from a simple mysql select query. Currently (shown
I have a List generated from JSON data in Sencha Touch. Essentially, the list
I have a simple form that has a list (dropdown list generated from a
I have this scenario. I have 10 checkboxes that need to be generated(this list

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.