Keep the middle item centered when side items have different widths

后端 未结 7 1198
长情又很酷
长情又很酷 2020-11-22 17:09

Imagine the following layout, where the dots represent the space between the boxes:

[Left box]......[Center box]......[Right box]

7条回答
  •  悲&欢浪女
    2020-11-22 17:59

    Here is another way to do it, using display: flex in the parents and childs:

    .Layout{
        display: flex;
        justify-content: center;
    }
    .Left{
        display: flex;
        justify-content: flex-start;
        width: 100%;
    }
    .Right{
        display: flex;
        justify-content: flex-end;
        width: 100%;
    }
    I'm on the left
    Centered
    I'm on the right

提交回复
热议问题