Responsive table by columns

后端 未结 5 777
花落未央
花落未央 2021-01-02 06:41

I have a table with four columns and I need to have a responsive table where each column will be below the other but I don\'t know how to do it. I hope that there is some an

5条回答
  •  隐瞒了意图╮
    2021-01-02 07:07

    Table have a problem with responsivity, because table datas are written by lines, so data in code looks thus: A, B, C, D, A, B, C, D... not A, A, A, A, B, B, B, B...

    So you not get output with datas in the right order.

    If you use media query, output looks thus:

    @media all and (max-width:500px){
        table{
            width:100%;
        }
    
        td{
            display:block;
            width:100%;
        }
    
        tr{
            display:block;
            margin-bottom:30px;
        }
    }
    

    http://jsfiddle.net/sjdjrm8m/


    You need convert your table to this enrollment:

    HTML:

    Some title
     Title
    40.000 eur
    month
     Text

    Lorem Ipsum

    Lorem Ipsum

    Lorem Ipsum

     Title2
    40.000 eur
    month
     Text

    Lorem Ipsum

    Lorem Ipsum

    Lorem Ipsum

    CSS:

    @media all and (max-width:500px){
        table{
            width:100%;
        }
    
        td{
            display:block;
            width:100%;
        }
    
        tr{
            display:block;
            margin-bottom:30px;
        }
    
        tr tr{
            margin-bottom:0;
        }
    }
    

    http://jsfiddle.net/9yefftan/

    提交回复
    热议问题