4

以下のHTML and CSSコードを使用してvertical、リストを並べ替えます。出力はhorizontal並べ替えられます。

私のコード例:

<!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>

出力は次のとおりです。

ここに画像の説明を入力

しかし、私はこの出力が欲しいです。

ここに画像の説明を入力

のソートリストのコードを教えてくださいvertical

4

2 に答える 2

9

CSS 列を使用する: ( 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;
}

これは IE≤9 では機能しないことに注意してください。

于 2012-12-13T08:25:30.647 に答える
0

CSS

    #tiles {         
        list-style: none;        
        margin: 0px; 
        width:300px;
        height:200px;   
          }     
     ul   {
        column-width: 85px;
        -webkit-column-width:85px;
        -moz-column-width: 85px;
        height:60px;
         }

    #tiles li {         
        float: left;
        margin: 20px;        
        width: 50px;         
        height: 30px;         
        background-color: #dddddd;         
        font-size: 16px;         
        text-align: center;         
        vertical-align: middle;     }

フィドルを見る

これは出力画像としてのシュラウドです

于 2012-12-13T08:32:06.823 に答える