显示flex,将div对准其容器的右下角

Rad*_*dex 1 html css css3 flexbox

我需要在其红色容器“内容”的右下角显示黄色的div“图标”。

我的脚本有什么问题?

.root {
    display: inline-flex;
    background-color: red;
}

.content {
    display: flex;
    align-items: centerl;
    justify-content: centerl;
    height: 80px;
    width: 100%;
    background-color: red;
}

.icon {
    position: absolute;
    right: 0;
    bottom:0;
    background-color: yellow;
}
Run Code Online (Sandbox Code Playgroud)
<div class="root">
    <div class="content">
        content
    </div>
    <div class="icon">
      icon
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Vik*_*hav 5

您可以使用flex end属性来代替位置 align-self: flex-end;

参见下面的代码片段:

.root {
  display: inline-flex;
  background-color: red;
}

.content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  width: 100%;
  background-color: red;
}

.icon {
   align-self: flex-end;
   background-color: yellow;
}
Run Code Online (Sandbox Code Playgroud)
<div class="root">
  <div class="content">
    content
  </div>
  <div class="icon">
    icon
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)