CSS Tables, Invert order of displayed content

后端 未结 2 847
孤街浪徒
孤街浪徒 2021-02-05 17:16

I know this is a bit bleeding edge, but here\'s the question anyway:

Given

First Div
Second Div&l
相关标签:
2条回答
  • 2021-02-05 18:19
        <div class="container">
            <div class="middle" style="background-color: blue;">
               <h4>Left Col placed middle</h4>
               <p>...</p>
            </div>
            <div class="right" style="background-color: red;">          
               <h4>Middle Col placed right side</h4>
               <p>...</p>
            </div>
            <div class="left" style="background-color: yellow;">
               <h4>Right Col placed left side</h4>
               <p>...</p>
            </div>
       </div>
    
    <style type="text/css">
        .container {
            display: flex;
        }
        .container > .left{
            order:1;
        }
        .container > .middle{           
            order:2;
        }
        .container > .right{
            order:3;
        }
    
        .left, .middle, .right {
            display:table-cell;         
        }
     </style>
    

    I use flexbox. You can also change count of divs. For example put more divs with left class, then they will be placed left side even if they are declared after.

    I tried @Greg example, but it doesn't work on IE.

    0 讨论(0)
  • 2021-02-05 18:21

    You can (ab)use the text direction warning, evil ahead:

    <div id="container">
        <div id="one">First Div</div>
        <div id="two">Second Div</div>
    </div>
    
    <style>
        #container { direction: rtl; }
        #one, #two { display: table-cell; direction: ltr;}
    </style>
    
    0 讨论(0)
提交回复
热议问题