Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort list in vertical?

Tags:

html

css

I'm using this below HTML and CSS code to sort list in vertical , the output is horizontal sorted.

My example code:

<!DOCTYPE HTML>
<html>
  <head>
    <title>Tiles</title>
    <style type="text/css">
    #tiles {
        list-style: none;
        margin: 0px;
    }
    #tiles li {
        float: left;
        margin: 20px;
        width: 300px;
        height: 200px;
        background-color: #dddddd;
        font-size: 72px;
        text-align: center;
        vertical-align: middle;
    }
    </style>
  </head>
  <body>
    <ul id="tiles">
       <li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li>
    </ul>
  </body>
</html>

Output is :

enter image description here

But , I want this output.

enter image description here

Please give me code for sort list in vertical.

like image 355
Jooxa Avatar asked Jan 15 '23 18:01

Jooxa


1 Answers

Use CSS columns: (JSFiddle)

ul {
    column-width: 380px;
    -webkit-column-width:380px;
    -moz-column-width: 380px;
    height:440px;
}

#tiles {
    list-style: none;
    margin: 0px;
}
#tiles li {
    /* float: left; */
    margin: 20px;
    width: 300px;
    height: 200px;
    background-color: #dddddd;
    font-size: 72px;
    text-align: center;
    vertical-align: middle;
}

Note that this won't work in IE≤9.

like image 112
Zeta Avatar answered Jan 17 '23 17:01

Zeta