How to layout list items in groups


Tags: html,css,css3

Problem :

Let's say we have a html list like this:

<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    ...
    <li>10</li>
</ul>

How to, using css and/or java script, make a browser show it like this (in groups of four, with some margin between the groups):

1 2    5 6    9 10
3 4    7 8    


Solution :

you can use css3 column-count property for this:

Write like this:

.colWrap {
    -webkit-column-count: 3;
    -moz-column-count: 3;
    -o-column-count: 3;
    -ms-column-count: 3;
    column-count: 3;
    -webkit-column-width:20px;
    -moz-column-width:20px;
}
li {
    display:inline;
}
div{
    width:120px;
}

Check this http://jsfiddle.net/rJTGJ/2/


    CSS Howto..

    How do I change a specific css element with javascript?

    How To Left Align the Title Using CSS

    CSS: How to force objects to stay inside container but allow full width background? [duplicate]

    how do i make the “box-shadow” to the whole div

    How do I remove all of the borders from an HTML ? [closed]
    Bootstrap is adding a top border to all td elements in .table containers. Adding ! important to your no-borders rule will override that: td { border: none !important; } ...
    Read more

    How do I remove the text underline (that I set myself) from a on hover?

    How to stop text from overlapping CSS?

    CSS - how to set a position of UL in LI

    How to inherit photo when hover on links under navigation bar?

    How can I avoid my headers and footers being broken when displaying content wider than the viewport?

    Android App with HTML/CSS/jQuery. [How] Can it be done?

    How to implement CSS file style on selected div

    How to add text to a CSS Sprite

    How to change Kendo Excel Button Content Text

    How to show only the div with id while hiding other divs using CSS only

    Why does a div with background-color show fixed elements below?

    StackLayoutPanel Shows white ends at the rounded corners

    How can I avoid CSS delay in Rails 3.2

    how to make css contents like boxes, text as center?

    How to click on and off submenu's using javascript

    How to label ABC in a HTML button and Click events

    How to validate HTML/CSS running in localhost?

    How do I make my elements occupy the width of their “max-width” specification?

    How to add styles based on whether top element is empty

    How to properly center a 100% width div in css

    How to get the type word inside the input field once after pressing the Comma key and not after pressing space bar

    How can I change css stylesheet with dart?

    How to style HTML5 input type=“datetime-local” [duplicate]

    How do I select text after a

    tag, but before a nested tag?

    How to get my “Register Now!” Link's to line up at the bottom using CSS

    and CSS in Firefox?
    How to set Highcharts data series in x-axis using crosshairs?
    CSS: How to style text in a box with a limited height
    How to override Inline Style CSS?
    How to repeat a menu without using iFrames or PHP in simple HTML/CSS or XML?
    CSS- how to prevent the original title info to be displayed
    How to precisely center bootstrap grid in html page?
    How to display css multiple columns with dynamic height
    How to maximum size without exceed the size?
    How to display last div at top using CSS?
    How to make a Facebook-image-style web design using CSS3?
    How to center text inside div in this specific situation? [duplicate]
    how to add css background color for div tag
    How to make semi-transparent select2?
    how to use javascript if in IE but use css for all other browsers?
    How to wrap lines in an inline-block with CSS?
    How to add a third level to my CSS drop down menu
    How to change css for each additional innerHTML element in a javascript for loop
    CSS: How to load a css file for all browsers except IE?
    How to access and modify imported .css files in WordPress style.css file?
    How can I remove the spacing above a block element in CSS?
    How to make interactive logo design without flash?
    How can I style dynamically created elements within an iframe?
    CSS: How can i divide a border into two lines? [duplicate]
    how to make css curve box with gradient & shadow
    How can I map 5 distinct zone on a draggable-vertical element?
    How to position elements with flex [duplicate]
    How can I make the CSS-hover animation to stay?