CSS Table-Like alignment using no tables? (CSS RelativeLayout)

后端 未结 2 652
鱼传尺愫
鱼传尺愫 2021-02-05 07:05

Wherever I go on the internet, I am constantly having it beat into me that I should not use Tables. Sadly, I am one of the few programmers who is stubborn enough to still be usi

2条回答
  •  天命终不由人
    2021-02-05 07:30

    I think for using pure CSS, with no Width, and no using table you can use Flex Layout

    This is the code

    HTML

    1asdf
    2
    1
    2

    CSS

    .flexrow {
        display: -webkit-flex;
        display: -moz-flex;
        display: -ms-flex;
        display: -o-flex;
        -webkit-justify-content: space-between;
        -moz-justify-content: space-between;
        -ms-justify-content: space-between;
        -o-justify-content: space-between;
        margin-bottom: 10px;
        -webkit-align-items: center;
        -moz-align-items: center;
        -ms-align-items: center;
        -o-align-items: center;
        -webkit-flex: none;
        -moz-flex: none;
        -ms-flex: none;
        -o-flex: none;
    }
    .item {
        -webkit-flex: 1;
        -moz-flex: 1;
        -ms-flex: 1;
        -o-flex: 1;
        margin: auto 10px;
        border-radius: 5px;
        border:1px solid black;
    }
    

    Here is the JsFiddle

提交回复
热议问题