Python私教张大鹏万字长文讲解Tailwindcss Flex 和 Grid 布局相关的样式,附完整源码和效果截图

flex-basics 样式类

Utilities for controlling the initial size of flex items.

用于控制伸缩项的初始大小的实用程序。

基础样式

ClassProperties
basis-0flex-basis: 0px;
basis-1flex-basis: 0.25rem; /* 4px */
basis-2flex-basis: 0.5rem; /* 8px */
basis-3flex-basis: 0.75rem; /* 12px */
basis-4flex-basis: 1rem; /* 16px */
basis-5flex-basis: 1.25rem; /* 20px */
basis-6flex-basis: 1.5rem; /* 24px */
basis-7flex-basis: 1.75rem; /* 28px */
basis-8flex-basis: 2rem; /* 32px */
basis-9flex-basis: 2.25rem; /* 36px */
basis-10flex-basis: 2.5rem; /* 40px */
basis-11flex-basis: 2.75rem; /* 44px */
basis-12flex-basis: 3rem; /* 48px */
basis-14flex-basis: 3.5rem; /* 56px */
basis-16flex-basis: 4rem; /* 64px */
basis-20flex-basis: 5rem; /* 80px */
basis-24flex-basis: 6rem; /* 96px */
basis-28flex-basis: 7rem; /* 112px */
basis-32flex-basis: 8rem; /* 128px */
basis-36flex-basis: 9rem; /* 144px */
basis-40flex-basis: 10rem; /* 160px */
basis-44flex-basis: 11rem; /* 176px */
basis-48flex-basis: 12rem; /* 192px */
basis-52flex-basis: 13rem; /* 208px */
basis-56flex-basis: 14rem; /* 224px */
basis-60flex-basis: 15rem; /* 240px */
basis-64flex-basis: 16rem; /* 256px */
basis-72flex-basis: 18rem; /* 288px */
basis-80flex-basis: 20rem; /* 320px */
basis-96flex-basis: 24rem; /* 384px */
basis-autoflex-basis: auto;
basis-pxflex-basis: 1px;
basis-0.5flex-basis: 0.125rem; /* 2px */
basis-1.5flex-basis: 0.375rem; /* 6px */
basis-2.5flex-basis: 0.625rem; /* 10px */
basis-3.5flex-basis: 0.875rem; /* 14px */
basis-1/2flex-basis: 50%;
basis-1/3flex-basis: 33.333333%;
basis-2/3flex-basis: 66.666667%;
basis-1/4flex-basis: 25%;
basis-2/4flex-basis: 50%;
basis-3/4flex-basis: 75%;
basis-1/5flex-basis: 20%;
basis-2/5flex-basis: 40%;
basis-3/5flex-basis: 60%;
basis-4/5flex-basis: 80%;
basis-1/6flex-basis: 16.666667%;
basis-2/6flex-basis: 33.333333%;
basis-3/6flex-basis: 50%;
basis-4/6flex-basis: 66.666667%;
basis-5/6flex-basis: 83.333333%;
basis-1/12flex-basis: 8.333333%;
basis-2/12flex-basis: 16.666667%;
basis-3/12flex-basis: 25%;
basis-4/12flex-basis: 33.333333%;
basis-5/12flex-basis: 41.666667%;
basis-6/12flex-basis: 50%;
basis-7/12flex-basis: 58.333333%;
basis-8/12flex-basis: 66.666667%;
basis-9/12flex-basis: 75%;
basis-10/12flex-basis: 83.333333%;
basis-11/12flex-basis: 91.666667%;
basis-fullflex-basis: 100%;

案例:控制flex子元素大小

Use the basis-{size} utilities to set the initial size of flex items.

使用basis-{size}实用程序来设置伸缩项的初始大小。

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 basis-1/2  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

代码说明:

  • basis-1/4:占据四分之一
  • basis-1/2:占据二分之一
  • rounded:圆角

在这里插入图片描述

flex-direction 相关的样式类

Utilities for controlling the direction of flex items.

用于控制伸缩项方向的实用程序。

基础样式

lassProperties
flex-rowflex-direction: row;
flex-row-reverseflex-direction: row-reverse;
flex-colflex-direction: column;
flex-col-reverseflex-direction: column-reverse;

案例:按行排列

Use flex-row to position flex items horizontally in the same direction as text:

使用flex-row可以在与文本相同的方向上水平定位伸缩项:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8 flex-row">
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 basis-1/2  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:按行反序排列

Use flex-row-reverse to position flex items horizontally in the opposite direction:

使用flex-row-reverse可将伸缩项水平放置在相反方向上:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8 flex-row-reverse">
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 basis-1/2  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:按列排列

Use flex-col to position flex items vertically:

使用flex-col垂直定位伸缩项:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8 flex-col">
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 basis-1/2  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:按列反序排列

Use flex-col-reverse to position flex items vertically in the opposite direction:

使用flex-col-reverse将伸缩项垂直放置在相反方向:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8 flex-col-reverse">
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 basis-1/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 basis-1/2  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

flex-wrap 相关的样式类

Utilities for controlling how flex items wrap.

用于控制弹性项目自动换行的实用程序。

基础样式

ClassProperties
flex-wrapflex-wrap: wrap;
flex-wrap-reverseflex-wrap: wrap-reverse;
flex-nowrapflex-wrap: nowrap;

案例:自动换行

Use flex-nowrap to prevent flex items from wrapping, causing inflexible items to overflow the container if necessary:

使用flex-nowrap防止有弹性的项目包装,导致不灵活的项目溢出容器(如有必要):

Use flex-wrap to allow flex items to wrap:

使用flex-wrap允许flex项目自动换行:

vue3示例:

<template>
  <div class="flex flex-wrap gap-3 bg-indigo-50 p-8">
    <div class="h-32 bg-purple-500 w-3/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 w-3/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 w-3/4  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:自动换行并反序

Use flex-wrap-reverse to wrap flex items in the reverse direction:

使用flex-wrap-reverse以相反的方向包装伸缩项目:

vue3示例:

<template>
  <div class="flex flex-wrap-reverse gap-3 bg-indigo-50 p-8">
    <div class="h-32 bg-purple-500 w-3/4  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="h-32 bg-purple-500 w-3/4  rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="h-32 bg-purple-500 w-3/4  rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

flex 相关的样式类

Utilities for controlling how flex items both grow and shrink.

用于控制伸缩项如何增长和收缩的实用程序。

基础样式

ClassProperties
flex-1flex: 1 1 0%;
flex-autoflex: 1 1 auto;
flex-initialflex: 0 1 auto;
flex-noneflex: none;

案例:自动对齐初始元素高度

Use flex-initial to allow a flex item to shrink but not grow, taking into account its initial size:

使用flex-initial允许伸缩项收缩而不是增长,考虑到它的初始大小:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-initial w-64 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-initial w-64 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:自动分配剩余空间大小

Use flex-1 to allow a flex item to grow and shrink as needed, ignoring its initial size:

使用flex-1允许伸缩项根据需要增长和缩小,忽略其初始大小:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:按照初始宽度自动增长

Use flex-auto to allow a flex item to grow and shrink, taking into account its initial size:

使用flex-auto允许伸缩项根据其初始大小进行增长和收缩:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-auto w-64 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-auto w-32 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:防止增长

Use flex-none to prevent a flex item from growing or shrinking:

使用flex-none来防止伸缩项的增长或收缩:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-none w-64 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-1 w-32 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

flex-grow 相关的样式类

Utilities for controlling how flex items grow.

用于控制伸缩项如何增长的实用程序。

基础样式

ClassProperties
growflex-grow: 1;
grow-0flex-grow: 0;

案例:自动增长

Use grow to allow a flex item to grow to fill any available space:

使用grow允许伸缩项增长以填充任何可用空间:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="grow  w-64 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-none w-32 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:防止增长

Use grow-0 to prevent a flex item from growing:

使用grow-0来防止伸缩项的增长:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="grow-0 w-64 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-none w-32 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

flex-shrink 相关的样式类

Utilities for controlling how flex items shrink.

用于控制伸缩项收缩方式的实用程序。

基础样式

ClassProperties
shrinkflex-shrink: 1;
shrink-0flex-shrink: 0;

案例:自动收缩

Use shrink to allow a flex item to shrink if needed:

使用收缩来允许伸缩项在需要时收缩:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="shrink w-96 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-none w-14 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:防止收缩

Use shrink-0 to prevent a flex item from shrinking:

使用shrink-0来防止伸缩项目收缩:

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="shrink-0 w-96 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-none w-14 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

order 相关的样式类

Utilities for controlling the order of flex and grid items.

用于控制伸缩和网格项的顺序的实用程序。

基础样式

ClassProperties
order-1order: 1;
order-2order: 2;
order-3order: 3;
order-4order: 4;
order-5order: 5;
order-6order: 6;
order-7order: 7;
order-8order: 8;
order-9order: 9;
order-10order: 10;
order-11order: 11;
order-12order: 12;
order-firstorder: -9999;
order-lastorder: 9999;
order-noneorder: 0;

案例:控制元素的显示顺序

Use order-{order} to render flex and grid items in a different order than they appear in the DOM.

使用order-{order}以不同于它们在DOM中显示的顺序来呈现flex和grid项。

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-none w-14 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="shrink-0 w-96 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="order-first flex-none w-14 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:顺序可以是负数

To use a negative order value, prefix the class name with a dash to convert it to a negative value.

若要使用负序值,请在类名前加上破折号以将其转换为负值。

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="-order-1 flex-none w-24 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">-order-1</div>
    <div class="shrink-0 w-96 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-none w-14 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
  <hr>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="order-1 flex-none w-24 h-14 bg-purple-500  rounded text-white font-bold flex items-center justify-center">order-1</div>
    <div class="shrink-0 w-96 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-none w-14 h-14 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

grid-template-columns 相关的样式类

Utilities for specifying the columns in a grid layout.

用于指定网格布局中的列的实用程序。

基础样式

ClassProperties
grid-cols-1grid-template-columns: repeat(1, minmax(0, 1fr));
grid-cols-2grid-template-columns: repeat(2, minmax(0, 1fr));
grid-cols-3grid-template-columns: repeat(3, minmax(0, 1fr));
grid-cols-4grid-template-columns: repeat(4, minmax(0, 1fr));
grid-cols-5grid-template-columns: repeat(5, minmax(0, 1fr));
grid-cols-6grid-template-columns: repeat(6, minmax(0, 1fr));
grid-cols-7grid-template-columns: repeat(7, minmax(0, 1fr));
grid-cols-8grid-template-columns: repeat(8, minmax(0, 1fr));
grid-cols-9grid-template-columns: repeat(9, minmax(0, 1fr));
grid-cols-10grid-template-columns: repeat(10, minmax(0, 1fr));
grid-cols-11grid-template-columns: repeat(11, minmax(0, 1fr));
grid-cols-12grid-template-columns: repeat(12, minmax(0, 1fr));
grid-cols-nonegrid-template-columns: none;
grid-cols-subgridgrid-template-columns: subgrid;

案例:使用网格布局

Use the grid-cols-{n} utilities to create grids with n equally sized columns.

使用grid-cols-{n}实用程序创建具有n个大小相等的列的网格。

vue3示例:

<script setup>
</script>
<template>
  <div class="grid grid-cols-4 gap-4 bg-indigo-50 p-3">
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">03</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">05</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">06</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">07</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">08</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">09</div>
  </div>
</template>

在这里插入图片描述

案例:子网格布局

Use the grid-cols-subgrid utility to adopt the column tracks defined by the item’s parent.

使用grid-cols-subgrid实用程序来采用项的父项定义的列轨道。

vue3案例:

<script setup>
</script>
<template>
  <div class="grid grid-cols-4 gap-4 bg-indigo-50 p-3">
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">03</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">05</div>
    <!--
    grid:网格布局
    grid-cols-subgrid:子网格布局
    gap-3:网格间隔3,和父容器一致
    col-span-3:合并3列网格
    col-start-2:跳过列,从第二列开始
    -->
    <div class="grid grid-cols-subgrid gap-3 col-span-3">
      <div class="col-start-2 bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">06</div>
    </div>
  </div>
</template>

在这里插入图片描述

grid-column 相关的样式类

Utilities for controlling how elements are sized and placed across grid columns.

用于控制元素在网格列之间的大小和放置方式的实用程序。

基础样式

ClassProperties
col-autogrid-column: auto;
col-span-1grid-column: span 1 / span 1;
col-span-2grid-column: span 2 / span 2;
col-span-3grid-column: span 3 / span 3;
col-span-4grid-column: span 4 / span 4;
col-span-5grid-column: span 5 / span 5;
col-span-6grid-column: span 6 / span 6;
col-span-7grid-column: span 7 / span 7;
col-span-8grid-column: span 8 / span 8;
col-span-9grid-column: span 9 / span 9;
col-span-10grid-column: span 10 / span 10;
col-span-11grid-column: span 11 / span 11;
col-span-12grid-column: span 12 / span 12;
col-span-fullgrid-column: 1 / -1;
col-start-1grid-column-start: 1;
col-start-2grid-column-start: 2;
col-start-3grid-column-start: 3;
col-start-4grid-column-start: 4;
col-start-5grid-column-start: 5;
col-start-6grid-column-start: 6;
col-start-7grid-column-start: 7;
col-start-8grid-column-start: 8;
col-start-9grid-column-start: 9;
col-start-10grid-column-start: 10;
col-start-11grid-column-start: 11;
col-start-12grid-column-start: 12;
col-start-13grid-column-start: 13;
col-start-autogrid-column-start: auto;
col-end-1grid-column-end: 1;
col-end-2grid-column-end: 2;
col-end-3grid-column-end: 3;
col-end-4grid-column-end: 4;
col-end-5grid-column-end: 5;
col-end-6grid-column-end: 6;
col-end-7grid-column-end: 7;
col-end-8grid-column-end: 8;
col-end-9grid-column-end: 9;
col-end-10grid-column-end: 10;
col-end-11grid-column-end: 11;
col-end-12grid-column-end: 12;
col-end-13grid-column-end: 13;
col-end-autogrid-column-end: auto;

案例:合并多列

Use the col-span-{n} utilities to make an element span n columns.

使用col-span-{n}实用程序使元素跨越n列。

vue3示例:

<script setup>
</script>
<template>
  <div class="grid grid-cols-3 gap-3 bg-indigo-50 p-3">
    <div class="bg-indigo-300 h-16 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="bg-indigo-300 h-16 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-indigo-300 h-16 rounded text-white font-bold flex items-center justify-center">03</div>
    <!--合并两列-->
    <div class="col-span-2 bg-indigo-700 h-16 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-indigo-300 h-16 rounded text-white font-bold flex items-center justify-center">05</div>
    <div class="bg-indigo-300 h-16 rounded text-white font-bold flex items-center justify-center">06</div>
    <!--合并两列-->
    <div class="col-span-2 bg-indigo-700 h-16 rounded text-white font-bold flex items-center justify-center">07</div>
  </div>
</template>

在这里插入图片描述

案例:开始列和结束列

Use the col-start-{n} and col-end-{n} utilities to make an element start or end at the nth grid line. These can also be combined with the col-span-{n} utilities to span a specific number of columns.

使用col-start-{n}和col-end-{n}实用程序使元素在第n个网格线上开始或结束。这些工具还可以与col-span-{n}实用程序组合使用,以跨越特定数量的列。

Note that CSS grid lines start at 1, not 0, so a full-width element in a 6-column grid would start at line 1 and end at line 7.

注意,CSS网格行从1开始,而不是0,所以6列网格中的全宽元素将从第1行开始,到第7行结束。

vue3示例:

<script setup>
</script>
<template>
  <!--grid的列是从1开始的。这里数量是6,所以列应该是:1、2、3、4、5、6-->
  <div class="grid grid-cols-6 gap-3 bg-indigo-50 p-3">
    <!--从第2列开始,合并4列-->
    <div class="col-start-2 col-span-4 bg-blue-500 h-16 rounded text-white font-bold flex items-center justify-center">01</div>
    <!--从第1列开始,在第3列结束-->
    <div class="col-start-1 col-end-3 bg-blue-500 h-16 rounded text-white font-bold flex items-center justify-center">02</div>
    <!--从第7列结束,合并2列-->
    <div class="col-end-7 col-span-2 bg-blue-500 h-16 rounded text-white font-bold flex items-center justify-center">03</div>
    <!--从第1列开始,在第7列结束-->
    <div class="col-start-1 col-end-7 bg-blue-500 h-16 rounded text-white font-bold flex items-center justify-center">04</div>
  </div>
</template>

在这里插入图片描述

grid-template-rows 相关的样式类

Utilities for specifying the rows in a grid layout.

用于指定网格布局中的行的实用程序。

基础示例

ClassProperties
grid-rows-1grid-template-rows: repeat(1, minmax(0, 1fr));
grid-rows-2grid-template-rows: repeat(2, minmax(0, 1fr));
grid-rows-3grid-template-rows: repeat(3, minmax(0, 1fr));
grid-rows-4grid-template-rows: repeat(4, minmax(0, 1fr));
grid-rows-5grid-template-rows: repeat(5, minmax(0, 1fr));
grid-rows-6grid-template-rows: repeat(6, minmax(0, 1fr));
grid-rows-7grid-template-rows: repeat(7, minmax(0, 1fr));
grid-rows-8grid-template-rows: repeat(8, minmax(0, 1fr));
grid-rows-9grid-template-rows: repeat(9, minmax(0, 1fr));
grid-rows-10grid-template-rows: repeat(10, minmax(0, 1fr));
grid-rows-11grid-template-rows: repeat(11, minmax(0, 1fr));
grid-rows-12grid-template-rows: repeat(12, minmax(0, 1fr));
grid-rows-nonegrid-template-rows: none;
grid-rows-subgridgrid-template-rows: subgrid;

案例:指定行数

Use the grid-rows-{n} utilities to create grids with n equally sized rows.

使用grid-rows-{n}实用程序创建具有n行大小相等的网格。

vue3示例:

<script setup>
</script>
<template>
  <!--
  grid:指定网格布局
  grid-rows-4:指定有4行
  grid-flow-col:指定自动计算列
  -->
  <div class="grid grid-rows-4 grid-flow-col gap-3 bg-indigo-50 p-3">
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">03</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">05</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">06</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">07</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">08</div>
    <div class="bg-pink-500 h-16 rounded text-white font-bold flex items-center justify-center">09</div>
  </div>
</template>

在这里插入图片描述

案例:子行网格布局

Use the grid-rows-subgrid utility to adopt the row tracks defined by the item’s parent.

使用网格-行-子网格实用程序来采用由项的父项定义的行轨迹。

vue3示例:

<script setup>
</script>
<template>
  <div class="grid grid-rows-4 grid-flow-col gap-3 bg-indigo-50 p-3">
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">03</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">05</div>
    <!--字网格布局-->
    <div class="grid grid-rows-subgrid gap-3 row-span-3">
      <div class="row-start-2 bg-fuchsia-600 h-16 rounded text-white font-bold flex items-center justify-center">06</div>
    </div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">07</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">08</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">09</div>
    <div class="bg-blue-300 h-16 rounded text-white font-bold flex items-center justify-center">10</div>
  </div>
</template>

在这里插入图片描述

grid-row 相关的样式类

Utilities for controlling how elements are sized and placed across grid rows.

用于控制元素大小和跨网格行放置方式的实用程序。

基础样式

ClassProperties
row-autogrid-row: auto;
row-span-1grid-row: span 1 / span 1;
row-span-2grid-row: span 2 / span 2;
row-span-3grid-row: span 3 / span 3;
row-span-4grid-row: span 4 / span 4;
row-span-5grid-row: span 5 / span 5;
row-span-6grid-row: span 6 / span 6;
row-span-7grid-row: span 7 / span 7;
row-span-8grid-row: span 8 / span 8;
row-span-9grid-row: span 9 / span 9;
row-span-10grid-row: span 10 / span 10;
row-span-11grid-row: span 11 / span 11;
row-span-12grid-row: span 12 / span 12;
row-span-fullgrid-row: 1 / -1;
row-start-1grid-row-start: 1;
row-start-2grid-row-start: 2;
row-start-3grid-row-start: 3;
row-start-4grid-row-start: 4;
row-start-5grid-row-start: 5;
row-start-6grid-row-start: 6;
row-start-7grid-row-start: 7;
row-start-8grid-row-start: 8;
row-start-9grid-row-start: 9;
row-start-10grid-row-start: 10;
row-start-11grid-row-start: 11;
row-start-12grid-row-start: 12;
row-start-13grid-row-start: 13;
row-start-autogrid-row-start: auto;
row-end-1grid-row-end: 1;
row-end-2grid-row-end: 2;
row-end-3grid-row-end: 3;
row-end-4grid-row-end: 4;
row-end-5grid-row-end: 5;
row-end-6grid-row-end: 6;
row-end-7grid-row-end: 7;
row-end-8grid-row-end: 8;
row-end-9grid-row-end: 9;
row-end-10grid-row-end: 10;
row-end-11grid-row-end: 11;
row-end-12grid-row-end: 12;
row-end-13grid-row-end: 13;
row-end-autogrid-row-end: auto;

案例:合并多行

Use the row-span-{n} utilities to make an element span n rows.

使用row-span-{n}实用程序使元素跨越n行。

vue3案例:

<script setup>
</script>
<template>
  <div class="grid grid-rows-3 grid-flow-col gap-3 bg-indigo-50 p-3">
    <!--合并3行-->
    <div class="row-span-3 bg-purple-500 h-56 rounded text-white font-bold flex items-center justify-center">01</div>
    <!--合并2列-->
    <div class="col-span-2 bg-purple-400 h-20 rounded text-white font-bold flex items-center justify-center">02</div>
    <!--合并2行2列-->
    <div class="row-span-2 col-span-2 bg-purple-500 h-32 rounded text-white font-bold flex items-center justify-center">03</div>
  </div>
</template>

在这里插入图片描述

案例:开始行和结束行

Use the row-start-{n} and row-end-{n} utilities to make an element start or end at the nth grid line. These can also be combined with the row-span-{n} utilities to span a specific number of rows.

使用row-start-{n}和row-end-{n}实用程序使元素在第n个网格行开始或结束。这些工具还可以与row-span-{n}实用程序结合使用,以跨越特定数量的行。

Note that CSS grid lines start at 1, not 0, so a full-height element in a 3-row grid would start at line 1 and end at line 4.

注意,CSS网格行从1开始,而不是0,所以3行网格中的full-height元素将从第1行开始,到第4行结束。

vue3示例:

<script setup>
</script>
<template>
  <div class="grid grid-rows-3 grid-flow-col gap-3 bg-indigo-50 p-3">
    <!--从第2行开始,合并2行-->
    <div class="row-start-2 row-span-2 bg-blue-500 h-32 rounded text-white font-bold flex items-center justify-center">01</div>
    <!--从第3行结束,合并2列-->
    <div class="row-end-3 row-span-2 bg-blue-400 h-32 rounded text-white font-bold flex items-center justify-center">02</div>
    <!--从第1行开始,在第4行结束-->
    <div class="row-start-1 row-end-4 col-span-2 bg-blue-500 h-32 rounded text-white font-bold flex items-center justify-center">03</div>
  </div>
</template>

在这里插入图片描述

grid-auto-flow 相关的样式类

Utilities for controlling how elements in a grid are auto-placed.

用于控制网格中的元素如何自动放置的实用程序。

基础样式

ClassProperties
grid-flow-rowgrid-auto-flow: row;
grid-flow-colgrid-auto-flow: column;
grid-flow-densegrid-auto-flow: dense;
grid-flow-row-densegrid-auto-flow: row dense;
grid-flow-col-densegrid-auto-flow: column dense;

案例:使用dense稠密堆积算法

Use the grid-flow-{keyword} utilities to control how the auto-placement algorithm works for a grid layout.

使用grid-flow-{关键字}实用程序来控制自动放置算法如何为网格布局工作。

该关键字指定自动布局算法使用一种“稠密”堆积算法,如果后面出现了稍小的元素,则会试图去填充网格中前面留下的空白。这样做会填上稍大元素留下的空白,但同时也可能导致原来出现的次序被打乱。

如果省略它,使用一种「稀疏」算法,在网格中布局元素时,布局算法只会「向前」移动,永远不会倒回去填补空白。这保证了所有自动布局元素「按照次序」出现,即使可能会留下被后面元素填充的空白。

vue3示例:

<script setup>
</script>
<template>
  <div class="grid grid-cols-3 grid-flow-row-dense gap-3 bg-indigo-50 p-3">
    <!--合并2列-->
    <div class="col-span-2 bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="col-span-2 bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-purple-500 h-32 rounded text-white font-bold flex items-center justify-center">03</div>
    <div class="bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">05</div>
  </div>
</template>

在这里插入图片描述

grid-auto-columns 相关的样式类

Utilities for controlling the size of implicitly-created grid columns.

用于控制隐式创建的网格列大小的实用程序。

基础样式

ClassProperties
auto-cols-autogrid-auto-columns: auto;
auto-cols-mingrid-auto-columns: min-content;
auto-cols-maxgrid-auto-columns: max-content;
auto-cols-frgrid-auto-columns: minmax(0, 1fr);

案例:

Use the auto-cols-{size} utilities to control the size of implicitly-created grid columns.

使用auto-cols-{size}实用程序来控制隐式创建的网格列的大小。

vue3示例:

<script setup>
</script>
<template>
  <div class="grid grid-cols-3 auto-cols-max gap-3 bg-indigo-50 p-3">
    <!--合并2列-->
    <div class="col-span-2 bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">01</div>
    <div class="col-span-2 bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">02</div>
    <div class="bg-purple-500 h-32 rounded text-white font-bold flex items-center justify-center">03</div>
    <div class="bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">04</div>
    <div class="bg-purple-200 h-32 rounded text-white font-bold flex items-center justify-center">05</div>
  </div>
</template>

在这里插入图片描述

grid-auto-rows 相关的样式类

Utilities for controlling the size of implicitly-created grid rows.

用于控制隐式创建的网格行的大小的实用程序。

基础样式

ClassProperties
auto-rows-autogrid-auto-rows: auto;
auto-rows-mingrid-auto-rows: min-content;
auto-rows-maxgrid-auto-rows: max-content;
auto-rows-frgrid-auto-rows: minmax(0, 1fr);

gap 相关的样式类

Utilities for controlling gutters between grid and flexbox items.

用于控制网格和弹性项目之间的沟槽的实用程序。

基础样式

ClassProperties
gap-0gap: 0px;
gap-x-0column-gap: 0px;
gap-y-0row-gap: 0px;
gap-pxgap: 1px;
gap-x-pxcolumn-gap: 1px;
gap-y-pxrow-gap: 1px;
gap-0.5gap: 0.125rem; /* 2px */
gap-x-0.5column-gap: 0.125rem; /* 2px */
gap-y-0.5row-gap: 0.125rem; /* 2px */
gap-1gap: 0.25rem; /* 4px */
gap-x-1column-gap: 0.25rem; /* 4px */
gap-y-1row-gap: 0.25rem; /* 4px */
gap-1.5gap: 0.375rem; /* 6px */
gap-x-1.5column-gap: 0.375rem; /* 6px */
gap-y-1.5row-gap: 0.375rem; /* 6px */
gap-2gap: 0.5rem; /* 8px */
gap-x-2column-gap: 0.5rem; /* 8px */
gap-y-2row-gap: 0.5rem; /* 8px */
gap-2.5gap: 0.625rem; /* 10px */
gap-x-2.5column-gap: 0.625rem; /* 10px */
gap-y-2.5row-gap: 0.625rem; /* 10px */
gap-3gap: 0.75rem; /* 12px */
gap-x-3column-gap: 0.75rem; /* 12px */
gap-y-3row-gap: 0.75rem; /* 12px */
gap-3.5gap: 0.875rem; /* 14px */
gap-x-3.5column-gap: 0.875rem; /* 14px */
gap-y-3.5row-gap: 0.875rem; /* 14px */
gap-4gap: 1rem; /* 16px */
gap-x-4column-gap: 1rem; /* 16px */
gap-y-4row-gap: 1rem; /* 16px */
gap-5gap: 1.25rem; /* 20px */
gap-x-5column-gap: 1.25rem; /* 20px */
gap-y-5row-gap: 1.25rem; /* 20px */
gap-6gap: 1.5rem; /* 24px */
gap-x-6column-gap: 1.5rem; /* 24px */
gap-y-6row-gap: 1.5rem; /* 24px */
gap-7gap: 1.75rem; /* 28px */
gap-x-7column-gap: 1.75rem; /* 28px */
gap-y-7row-gap: 1.75rem; /* 28px */
gap-8gap: 2rem; /* 32px */
gap-x-8column-gap: 2rem; /* 32px */
gap-y-8row-gap: 2rem; /* 32px */
gap-9gap: 2.25rem; /* 36px */
gap-x-9column-gap: 2.25rem; /* 36px */
gap-y-9row-gap: 2.25rem; /* 36px */
gap-10gap: 2.5rem; /* 40px */
gap-x-10column-gap: 2.5rem; /* 40px */
gap-y-10row-gap: 2.5rem; /* 40px */
gap-11gap: 2.75rem; /* 44px */
gap-x-11column-gap: 2.75rem; /* 44px */
gap-y-11row-gap: 2.75rem; /* 44px */
gap-12gap: 3rem; /* 48px */
gap-x-12column-gap: 3rem; /* 48px */
gap-y-12row-gap: 3rem; /* 48px */
gap-14gap: 3.5rem; /* 56px */
gap-x-14column-gap: 3.5rem; /* 56px */
gap-y-14row-gap: 3.5rem; /* 56px */
gap-16gap: 4rem; /* 64px */
gap-x-16column-gap: 4rem; /* 64px */
gap-y-16row-gap: 4rem; /* 64px */
gap-20gap: 5rem; /* 80px */
gap-x-20column-gap: 5rem; /* 80px */
gap-y-20row-gap: 5rem; /* 80px */
gap-24gap: 6rem; /* 96px */
gap-x-24column-gap: 6rem; /* 96px */
gap-y-24row-gap: 6rem; /* 96px */
gap-28gap: 7rem; /* 112px */
gap-x-28column-gap: 7rem; /* 112px */
gap-y-28row-gap: 7rem; /* 112px */
gap-32gap: 8rem; /* 128px */
gap-x-32column-gap: 8rem; /* 128px */
gap-y-32row-gap: 8rem; /* 128px */
gap-36gap: 9rem; /* 144px */
gap-x-36column-gap: 9rem; /* 144px */
gap-y-36row-gap: 9rem; /* 144px */
gap-40gap: 10rem; /* 160px */
gap-x-40column-gap: 10rem; /* 160px */
gap-y-40row-gap: 10rem; /* 160px */
gap-44gap: 11rem; /* 176px */
gap-x-44column-gap: 11rem; /* 176px */
gap-y-44row-gap: 11rem; /* 176px */
gap-48gap: 12rem; /* 192px */
gap-x-48column-gap: 12rem; /* 192px */
gap-y-48row-gap: 12rem; /* 192px */
gap-52gap: 13rem; /* 208px */
gap-x-52column-gap: 13rem; /* 208px */
gap-y-52row-gap: 13rem; /* 208px */
gap-56gap: 14rem; /* 224px */
gap-x-56column-gap: 14rem; /* 224px */
gap-y-56row-gap: 14rem; /* 224px */
gap-60gap: 15rem; /* 240px */
gap-x-60column-gap: 15rem; /* 240px */
gap-y-60row-gap: 15rem; /* 240px */
gap-64gap: 16rem; /* 256px */
gap-x-64column-gap: 16rem; /* 256px */
gap-y-64row-gap: 16rem; /* 256px */
gap-72gap: 18rem; /* 288px */
gap-x-72column-gap: 18rem; /* 288px */
gap-y-72row-gap: 18rem; /* 288px */
gap-80gap: 20rem; /* 320px */
gap-x-80column-gap: 20rem; /* 320px */
gap-y-80row-gap: 20rem; /* 320px */
gap-96gap: 24rem; /* 384px */
gap-x-96column-gap: 24rem; /* 384px */
gap-y-96row-gap: 24rem; /* 384px */

案例:统一控制行列间隙

Use gap-{size} to change the gap between both rows and columns in grid and flexbox layouts.

使用gap-{size}来改变网格和弹性布局中行和列之间的间隙。

vue3示例:

<template>
  <div class="flex gap-3 bg-indigo-50 p-8">
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>

  <hr>
  <div class="flex gap-8 bg-indigo-50 p-8">
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>

  <hr>
  <div class="flex gap-28 bg-indigo-50 p-8">
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="flex-1 bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:分别控制行列间隙

Use gap-x-{size} and gap-y-{size} to change the gap between columns and rows independently.

使用gap-x-{size}和gap-y-{size}分别更改列和行之间的间距。

vue3示例:

<template>
  <div class="flex flex-wrap gap-x-3 gap-y-5 bg-indigo-50 p-8">
    <div class="w-1/4 h-20 flex-grow flex-shrink bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20 flex-grow flex-shrink bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20 flex-grow flex-shrink bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
    <div class="w-1/4 h-20 flex-grow flex-shrink bg-purple-500 rounded text-white font-bold flex items-center justify-center">4</div>
    <div class="w-1/4 h-20 flex-grow flex-shrink bg-purple-500 rounded text-white font-bold flex items-center justify-center">5</div>
    <div class="w-1/4 h-20 flex-grow flex-shrink bg-purple-500 rounded text-white font-bold flex items-center justify-center">6</div>
  </div>
</template>

在这里插入图片描述

justify-content 相关的样式类

Utilities for controlling how flex and grid items are positioned along a container’s main axis.

用于控制flex和网格项沿容器主轴位置的实用程序。

基础样式

ClassProperties
justify-normaljustify-content: normal;
justify-startjustify-content: flex-start;
justify-endjustify-content: flex-end;
justify-centerjustify-content: center;
justify-betweenjustify-content: space-between;
justify-aroundjustify-content: space-around;
justify-evenlyjustify-content: space-evenly;
justify-stretchjustify-content: stretch;

案例:水平左对齐

Use justify-start to justify items against the start of the container’s main axis:

使用justify-start对容器主轴的起始位置进行对齐:

vue3示例:

<template>
  <div class="flex justify-start gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:水平居中对齐

Use justify-center to justify items along the center of the container’s main axis:

使用justify-center来对齐沿着容器主轴中心的项:

vue3示例:

<template>
  <div class="flex justify-center gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:水平右对齐

Use justify-end to justify items against the end of the container’s main axis:

使用justify-end将项对齐到容器主轴的末端:

vue3示例:

<template>
  <div class="flex justify-end gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:水平空格填充

Use justify-between to justify items along the container’s main axis such that there is an equal amount of space between each item:

使用justify-between沿容器的主轴对项目进行对齐,使每个项目之间有相等的空间:

vue3示例:

<template>
  <div class="flex justify-between gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:水平空格环绕

Use justify-around to justify items along the container’s main axis such that there is an equal amount of space on each side of each item:

使用左右对齐来对齐容器主轴上的项目,这样每个项目的每一边都有等量的空间:

vue3示例:

<template>
  <div class="flex justify-around gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>

  <hr>
  <div class="flex justify-between gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

案例:每个空隙都相等

Use justify-evenly to justify items along the container’s main axis such that there is an equal amount of space around each item, but also accounting for the doubling of space you would normally see between each item when using justify-around:

使用justify- average来对齐容器主轴上的条目,这样每个条目周围就有等量的空间,但也要考虑到使用justify-around时通常在每个条目之间看到的双倍空间:

vue3案例:

<script setup>
</script>
<template>
  <div class="flex justify-around gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>

  <hr>
  <div class="flex justify-between gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>

  <hr>
  <div class="flex justify-evenly gap-3 bg-indigo-50 p-8">
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">1</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">2</div>
    <div class="w-1/4 h-20  bg-purple-500 rounded text-white font-bold flex items-center justify-center">3</div>
  </div>
</template>

在这里插入图片描述

justify-around是左右两边的空隙是相等的。所以,第一个元素的左边空隙和最后一个元素的右边空隙,只有其他空隙的一半大。

justify-evenly是每个空隙都是相等的。

justify-items 相关的样式类

Utilities for controlling how grid items are aligned along their inline axis.

用于控制网格项沿其行内轴如何对齐的实用程序。

基础样式

ClassProperties
justify-items-startjustify-items: start;
justify-items-endjustify-items: end;
justify-items-centerjustify-items: center;
justify-items-stretchjustify-items: stretch;

justify-self 相关的样式类

Utilities for controlling how an individual grid item is aligned along its inline axis.

用于控制单个网格项沿其行内轴如何对齐的实用程序。

基础样式

ClassProperties
justify-self-autojustify-self: auto;
justify-self-startjustify-self: start;
justify-self-endjustify-self: end;
justify-self-centerjustify-self: center;
justify-self-stretchjustify-self: stretch;

algin-content 相关的样式类

Utilities for controlling how rows are positioned in multi-row flex and grid containers.

用于控制在多行伸缩容器和网格容器中如何定位行的实用程序。

基础样式

ClassProperties
content-normalalign-content: normal;
content-centeralign-content: center;
content-startalign-content: flex-start;
content-endalign-content: flex-end;
content-betweenalign-content: space-between;
content-aroundalign-content: space-around;
content-evenlyalign-content: space-evenly;
content-baselinealign-content: baseline;
content-stretchalign-content: stretch;

align-items 相关的样式类

基础样式

ClassProperties
items-startalign-items: flex-start;
items-endalign-items: flex-end;
items-centeralign-items: center;
items-baselinealign-items: baseline;
items-stretchalign-items: stretch;

align-self 相关的样式类

基础样式

ClassProperties
self-autoalign-self: auto;
self-startalign-self: flex-start;
self-endalign-self: flex-end;
self-centeralign-self: center;
self-stretchalign-self: stretch;
self-baselinealign-self: baseline;

place-content 相关的样式类

基础样式

ClassProperties
place-content-centerplace-content: center;
place-content-startplace-content: start;
place-content-endplace-content: end;
place-content-betweenplace-content: space-between;
place-content-aroundplace-content: space-around;
place-content-evenlyplace-content: space-evenly;
place-content-baselineplace-content: baseline;
place-content-stretchplace-content: stretch;

place-items 相关的样式类

基础样式

ClassProperties
place-items-startplace-items: start;
place-items-endplace-items: end;
place-items-centerplace-items: center;
place-items-baselineplace-items: baseline;
place-items-stretchplace-items: stretch;

place-self 相关的样式类

基础样式

ClassProperties
place-self-autoplace-self: auto;
place-self-startplace-self: start;
place-self-endplace-self: end;
place-self-centerplace-self: center;
place-self-stretchplace-self: stretch;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/676356.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

程序员的五大职业素养,你知道吗?

程序员职业生涯的挑战与机遇 在当今这个科技日新月异的时代&#xff0c;程序员作为技术行业的中坚力量&#xff0c;其职业生涯无疑充满了无数挑战与机遇。技术的快速迭代要求他们必须不断学习新知识、掌握新技能&#xff0c;以跟上时代的步伐。同时&#xff0c;云计算、人工智…

python常见数据分析函数

apply DataFrame.apply(func, axis0, broadcastFalse, rawFalse, reduceNone, args(), **kwds) 第一个参数是函数 可以在Series或DataFrame上执行一个函数 支持对行、列或单个值进行处理 import numpy as np import pandas as pdf lambda x: x.max()-x.min()df pd.DataFrame(…

Spring Cloud学习笔记(Nacos):Nacos持久化(未完成)

这是本人学习的总结&#xff0c;主要学习资料如下 - 马士兵教育 1、Overview2、单机使用MySQL 1、Overview 我们关闭单机下的Nacos后&#xff0c;再重新启动会发现之前配置的内容没有被删除。这时因为Nacos有内嵌的数据库derby&#xff0c;会自己持久化。 但是在集群的情况下…

【用户画像】用户偏好购物模型BP

一、前言 用户购物偏好模型BP&#xff08;Buyer Preferences Model&#xff09;旨在通过对用户购物行为的深入分析和建模&#xff0c;以量化用户对不同商品或服务的偏好程度。该模型对于电商平台、零售商以及其他涉及消费者决策的商业实体来说&#xff0c;具有重要的应用价值。…

尝试编译 AMD ROCm 的 llvm-project

0&#xff0c;环境 ubuntu 22.04 gcc-11 x86_64 18cores/36threads 256GB RAM rocm 6.0.2 Radeon VII 1&#xff0c;第一次尝试 构建命令&#xff1a; cmake -G "Unix Makefiles" ../llvm \ -DLLVM_ENABLE_PROJECTS"clang;lld;lldb;mlir;openmp" \…

TCP报头

TCP报头 一:TCP报头1.1: 16位源端口号 && 16位目的端口号1.2: 选项1.3: 4位首部长度1.4: 保留位1.5 :标志位1.6: 16位窗口大小1.7: 16位紧急指针1.8: 32位序号 && 32位确认序号1.9: 16位校验和二级目录 一级目录二级目录二级目录二级目录 一级目录一级目录一级…

[GeoServer系列]Shapefile数据发布

【GeoServer系列】——安装与发布shapefile数据-CSDN博客 将待发布数据放置指定目录下 webapps\geoserver\data\data 创建存储仓库 新建矢量数据源 发布图层 设置边框 设置样式 使用 方式1 let highRoad new Cesium.WebMapServiceImageryProvider({url: http://local…

一维时间序列信号的奇异小波时频分析方法(Python)

最初的时频分析技术就是短时窗傅里叶变换STFT&#xff0c;由于时窗变短&#xff0c;可供分析的信号量减少&#xff0c;采用经典的谱估算方法引起的误差所占比重会增加。且该短时窗一旦选定&#xff0e;则在整个变换过程中其时窗长度是固定的。变换后的时频分辨率也即固定&#…

分享两种论文降重最有效的方法(论文降重网站)

论文降重最有效的方法可以分为手动方法和使用降重网站两种方法。以下是详细的分析和归纳&#xff1a; 手动方法 删减冗余内容&#xff1a;对于论文中的某些内容&#xff0c;特别是信息冗余或不必要的描述&#xff0c;可以通过删减和简化来减少篇幅。确保每一段落和每一个例子都…

UI 自动化测试(Selenuim + Java )

关于 UI 自动化测试工具 selenuim Java 的环境搭建推荐看SeleniumJava 环境搭建 什么是自动化测试&#xff1f; 自动化测试指软件测试的自动化&#xff0c;在预设状态下运行应用程序或者系统&#xff0c;预设条件包括正常和异常&#xff0c;最后评估运行结果。将人为驱动的测…

AI大数据处理与分析实战--体育问卷分析

AI大数据处理与分析实战–体育问卷分析 前言&#xff1a;前一段时间接了一个需求&#xff0c;使用AI进行数据分析与处理&#xff0c;遂整理了一下大致过程和大致简要结果&#xff08;更详细就不方便放了&#xff09;。 文章目录 AI大数据处理与分析实战--体育问卷分析一、数据…

三十五、openlayers官网示例Dynamic Data——在地图上加载动态数据形成动画效果

官网demo地址&#xff1a; Dynamic Data 初始化地图 const tileLayer new TileLayer({source: new OSM(),});const map new Map({layers: [tileLayer],target: "map",view: new View({center: [0, 0],zoom: 2,}),}); 创建了三个样式 const imageStyle new Style(…

glibc backtrace backtrace_symbols 的应用示例

作用&#xff1a; 在一个函数调用栈中&#xff0c;输出 backtrace()函数返回时需要执行的下一条指令的地址&#xff0c;以及返回主调函数后的下一条指令的地址&#xff0c;递归上一步&#xff0c;直到从系统中链接进来的 _start() 为止。 1&#xff0c;示例先行 hello_glibc.…

动态sql set标签 , trim标签

set标签 来看例子 set标案解决了逗号问题(当if条件不满足时,逗号无处安放的问题),我认为set标签可以识别这个问题,并自动忽略这个问题 <update id"update">update employee<set><if test"name!null">name#{name},</if><if te…

vsode (Visual Studio Code) JS -- HTML 教程

vsode (Visual Studio Code) JS – HTML 教程 JavaScript 是什么 -JavaScript 是一种基于对象和事件驱动的脚本语言&#xff0c;广泛用于在网页上实现动态交互效果。JavaScript 可以嵌入到 HTML 页面中&#xff0c;通过在脚本标签中编写 JavaScript 代码来实现各种功能。它主要…

PCIe的链路状态

目录 概述 链路训练的目的 两个概念 下面介绍LTSSM状态机 概述 PCie链路的初始化过程较为复杂&#xff0c;Pcie总线进行链路训练时&#xff0c;将初始化Pcie设备的物理层&#xff0c;发送接收模块和相关的链路状态信息&#xff0c;当链路训练成功结束后&#xff0c;PCIe链…

心动(GDI+)

文章目录 前言实现步骤源代码心形坐标类心形函数定时器方法绘制函数完整源码 结束语 前言 近期学习了一段时间的GDI,突然想着用GDI绘制点啥&#xff0c;用来验证下类与方法。有兴趣的&#xff0c;可以查阅Windows GDI学习笔记相关文章。 效果展示 实现步骤 定义心形函数 。…

MobaXterm 连接时间太短,会自动断开

问题现象 MobaXterm成功连接到开发环境后&#xff0c;过一段时间会自动断开。 原因 配置MobaXterm工具时&#xff0c;没有勾选“SSH keepalive”或专业版MobaXterm工具的“Stop server after”时间设置太短。

C++ stack类与queue类

目录 0.前言 1.容器适配器 1.1容器适配器的特点 1.2容器适配器的实现 1.3使用容器适配器的场景 2.stack的介绍与使用 2.1介绍 2.2使用 3.queue的介绍与使用 3.1介绍 3.2使用 4.stack和queue的模拟实现 4.1 stack的模拟实现 4.2 queue的模拟实现 5.结语 &#xf…

探秘IPv6协议在车载网络的应用:打造智能出行新体验

绪论 1969年&#xff0c;互联网的前身——ARPANET成功地连接了四个关键节点&#xff1a;①加州大学洛杉矶分校、②斯坦福研究所、③加州大学圣巴巴拉分校、④犹他州大学。这四个节点的成功连接标志着分组交换&#xff08;Packet Switching&#xff09;网络的正式运行&#xff…