Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Absolutely position flex item test</title>
  <style>
  body {
    display: flex;
    flex-wrap: wrap;
    margin-top: 30px;
    font-size: 16px;
  }
  h2 {
    font-size: 14px;
    font-weight: normal;
  }
  .box {
    border: 1px solid #000;
    width: 180px;
    height: 180px;
    margin-bottom: 10px;
    margin-right: 10px;
    color: #fff;
    position: relative;
  }
  .flex {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .flex.multi-line {
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
  }
  .item {
    width: 100px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: green;
    z-index: 10;
  }
  .absolute {
    position: absolute;
    background-color: red;
  }
  </style>
</head>
<body>
  <!-- 'align-self: auto' compute or behave as 'start' for abspos? -->
  <!-- https://lists.w3.org/Archives/Public/www-style/2016Sep/0041.html -->
  <!-- <a href="Firefox 不支持 test-cace 3" target="_blank">https://bugzilla.mozilla.org/show_bug.cgi?id=874718#c29</a> -->
  <div class="test">
    <h2>single-line flexbox</h2>
    <div class="flex box">
      <div class="item">item 1</div>
      <div class="item absolute">item 2</div>
    </div>
  </div>
  <div class="test">
    <h2>multi-line flexbox</h2>
    <div class="flex multi-line box">
      <div class="item">item 1</div>
      <div class="item">item 2</div>
      <div class="item absolute">item 3</div>
    </div>
  </div>
  <div class="test">
    <h2>multi-line flexbox and use align-content</h2>
    <div class="flex multi-line align-content box">
      <div class="item">item 1</div>
      <div class="item">item 2</div>
      <div class="item absolute">item 3</div>
    </div>
  </div>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers