Flexbox - align-self: flex-end horizontally

后端 未结 3 1325
心在旅途
心在旅途 2021-01-01 10:49

How to align div.c to the right end with flexbox like below?

+--------------+ |A B C | +--------------+

The rule al

3条回答
  •  没有蜡笔的小新
    2021-01-01 11:28

    Updated answer

    As per new question, align a single item to the right by adding margin-left: auto; to that item.

    Demo

    Original answer Use the justify-content property on your container.

    .container {
      -webkit-justify-content: space-between;
      justify-content: space-between;
    }
    

    A good resource for flex properties here.

    Fiddle

    .container {
      border: 2px solid;
      height: 500px;
      display: flex;
      flex-direction: row;
      -webkit-justify-content: space-between;
      justify-content: space-between;
    }
    .box {
      border: 1px solid;
      height: 200px;
      width: 50px;
    }
    .a {
      background-color: red;
      align-self: flex-start;
    }
    .b {
      background-color: cyan;
      align-self: flex-end;
    }

提交回复
热议问题