<div class="title">
  <p>请使用Firefox浏览器查阅Demo效果</p>
  <p>Flex容器: width: 800px</p>
  <p>Flex容器: padding: 10px</p>
</div>
<div class="flex-container">
  <div class="flex-item" data-attr="auto">Flex Item</div>
  <div class="flex-item" data-attr="fill">Flex Item</div>
  <div class="flex-item" data-attr="max-content">Flex Item</div>
  <div class="flex-item" data-attr="min-content">Flex Item</div>
  <div class="flex-item" data-attr="fit-content">Flex Item</div>
  <div class="flex-item" data-attr="content">Flex Item</div>
  <div class="flex-item" data-attr="200px">Flex Item</div>
  <div class="flex-item" data-attr="20%">Flex Item</div>
</div>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  display: flex;
  flex-direction: column;
  // justify-content: center;
  align-items: center;
  width: 100vw;
  min-height: 100vh;
}

.flex-container {
  display: flex;
  width: 800px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-shadow: 0 0 3px 3px rgba(0,0,0,.125);
  position: relative;
  margin: 30px;
  flex-wrap: wrap;
  
  &::before {
    content: "flex container";
    position: absolute;
    padding: 10px;
    background: linear-gradient(to right, #f36, #f63);
    color: #fff;
    border-radius: 5px;
    top: 50%;
    right: calc(100% - 5px);
    transform: translate(0, -50%);
    white-space: nowrap;
  }
}

.flex-item {
  background: white;
  border-radius: 3px;
  // width: 150px;
  padding: 20px;
  position: relative;
  border: 1px solid #f3f;
  min-height: 60px;
  margin: 30px;
  // flex-grow: 0;
  // flex-shrink: 0;
  
  &::after {
    content: ':(flex-basis:' attr(data-attr) ')'
  }
  
  &::before {
    content: attr(data-attr);
    position: absolute;
    padding: 10px;
    background: linear-gradient(to right, #f36, #f63);
    color: #fff;
    white-space: nowrap;
    border-radius: 5px;
    top: -25px;
    left: 20px;
  }
  
  &[data-attr="auto"] {
    flex-basis: auto;
  }
  &[data-attr="fill"] {
    flex-basis: -webkit-fill-available;
    flex-basis: -moz-available;
    flex-basis: fill;
  }
  &[data-attr="max-content"] {
    flex-basis: -webkit-max-content;
    flex-basis: -moz-max-content;
    flex-basis: max-content;
  }
  &[data-attr="min-content"] {
    flex-basis: -webkit-min-content;
    flex-basis: -moz-min-content;
    flex-basis: min-content;
  }
  &[data-attr="fit-content"] {
    flex-basis: -webkit-fit-content;
    flex-basis: -moz-fit-content;
    flex-basis: fit-content;
  }
  &[data-attr="content"] {
    flex-basis: content;
  }
  &[data-attr="200px"] {
    flex-basis: 200px;
  }
  &[data-attr="20%"] {
    flex-basis: 20%;
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.