语法

flex-wrap: nowrap | wrap | wrap-reverse | initial | inherit;

具有“wrap”值的 flex-wrap 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .wrap {
        width: 200px;
        height: 200px;
        border: 1px solid #cccccc;
        display: -webkit-flex;
        -webkit-flex-wrap: wrap;
        display: flex;
        flex-wrap: wrap;
      }
      .wrap div {
        width: 50px;
        height: 50px;
      }
    </style>
  </head>
  <body>
    <h2>The flex-wrap Property</h2>
    <div class="wrap">
      <div style="background-color:coral;">A</div>
      <div style="background-color:lightblue;">B</div>
      <div style="background-color:khaki;">C</div>
      <div style="background-color:pink;">D</div>
      <div style="background-color:lightgrey;">E</div>
      <div style="background-color:lightgreen;">F</div>
    </div>
  </body>
</html>

具有“nowrap”值的 flex-wrap 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .example {
        width: 200px;
        height: 200px;
        border: 1px solid #c3c3c3;
        display: -webkit-flex;
        -webkit-flex-wrap: nowrap;
        display: flex;
        flex-wrap: nowrap;
      }
      .example div {
        width: 50px;
        height: 50px;
      }
    </style>
  </head>
  <body>
    <h2>Flex-wrap 属性示例</h2>
    <div class="example">
      <div style="background-color: #8ebf42;">A</div>
      <div style="background-color: #1c87c9;">B</div>
      <div style="background-color: #cccccc;">C</div>
      <div style="background-color: #666666;">D</div>
      <div style="background-color: #4c4a4a;">E</div>
      <div style="background-color: #c6c4c4;">F</div>
    </div>
  </body>
</html>

具有“wrap-reverse”值的 flex-wrap 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .example {
        width: 200px;
        height: 200px;
        border: 1px solid #c3c3c3;
        display: -webkit-flex;
        -webkit-flex-wrap: wrap-reverse;
        display: flex;
        flex-wrap: wrap-reverse;
      }
      .example div {
        width: 50px;
        height: 50px;
      }
    </style>
  </head>
  <body>
    <h2>Flex-wrap 属性示例</h2>
    <div class="example">
      <div style="background-color: #8ebf42;">A</div>
      <div style="background-color: #1c87c9;">B</div>
      <div style="background-color: #cccccc;">C</div>
      <div style="background-color: #666666;">D</div>
      <div style="background-color: #4c4a4a;">E</div>
      <div style="background-color: #c6c4c4;">F</div>
    </div>
  </body>
</html>

CSS flex-wrap 属性值说明

描述
nowrap定义灵活的项目(item)(item)不会包装。这是此属性的默认值。
wrap定义灵活的物品在需要时会缠绕。
wrap-reverse定义灵活的物品在需要时将以相反的顺序包装。
initial使属性使用其默认值。
inherit从父母元素继承属性。
CSS flex-wrap 属性

flex-wrap 属性定义了柔性项目(item)(item)是否应该换行。
换句话说,它定义了项目(item)(item)是强制进入单行还是项目(item)(item)可以在多行上流动。

如果没有弹性项目(item)(flex item),则 flex-wrap 属性将不起作用。

flex-wrap 属性是 CSS3 属性之一。

初始值noprop.
应用于柔性容器。
继承无效
可动画的无效
版本CSS3.
DOM 语法object.style.flexwrap ="wrap-reverse";
日期:2020-06-02 22:14:30 来源:oir作者:oir