Can I order my CSS columns horizontally instead of vertically?

前端 未结 5 1811
南笙
南笙 2021-02-01 17:25

Here is my code:



        
相关标签:
5条回答
  • 2021-02-01 17:55

    I actually put some effort forward this time. ignore everything from previous edit

    the display property's inline-blocks is probably what you want to use.

    Here is a thorough guide on how to use it

    And here's a brief demo

    li {
        width: 200px;
        display: inline-block;
    }
    
    0 讨论(0)
  • 2021-02-01 18:00

    Apply this:

    .column { 
      width: 100px; 
      overflow:hidden;
    } 
    .column .inner {
      width:  20px; 
      float:left; 
      text-align:center;
    }
    
    0 讨论(0)
  • 2021-02-01 18:08

    check my simple codes below url. https://github.com/JJ81/column-count maybe you can have what you want.

    0 讨论(0)
  • 2021-02-01 18:09

    Is even easier:

    .inner:nth-child(4n+1) {
        clear: left;
    }
    
    .inner {
        float: left;
        margin: 5px;
    }
    <div class="column">
        <div class="inner">1</div>
        <div class="inner">2</div>
        <div class="inner">3</div>
        <div class="inner">4</div>
        <div class="inner">5</div>
        <div class="inner">6</div>
        <div class="inner">7</div>
        <div class="inner">8</div>
        <div class="inner">9</div>
        <div class="inner">10</div>
        <div class="inner">11</div>
        <div class="inner">12</div>
    </div>

    You can apply float: left and clear float: left every 4n+1 elements.

    Ref:

    :nth-child

    0 讨论(0)
  • 2021-02-01 18:11

    Mansonry.js is the solution. Check this out http://masonry.desandro.com/ Also check out this demo. This is what you need i guess.. I am also trying to implement such thing :) http://tympanus.net/Development/GridLoadingEffects/index2.html

    As far as I know there's no way to do this with CSS only which is sad

    0 讨论(0)
提交回复
热议问题