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;

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JDBC 学习笔记(一)基础篇 - JDBC 搭建的六大步骤

JDK 版本使用&#xff1a;JDK 21 框架思想&#xff1a;实体类及ORM思想 反射技术&#xff1a;BaseDAO 封装的过程 解决现有问题的角度&#xff0c;主要是 JDBC的基础应用 一、、JDBC 可以解决的问题 1.1 数据存储的问题 解决数据长期的存储问题&#xff1a; 数据通过 I/O 流…

城市之旅:使用 LLM 和 Elasticsearch 简化地理空间搜索(一)

作者&#xff1a;来自 Elastic Philipp Kahr, Valentin Crettaz 这篇博文的本地部署实践 Jupyter notebook 请详细阅读文章 “城市之旅&#xff1a;使用 LLM 和 Elasticsearch 简化地理空间搜索&#xff08;二&#xff09;”。 探索如何从自然语言提问创建地理空间搜索。在下…

最新鸿蒙南北开发学习路线+学习资料分享

前言 5月29日&#xff0c;“千帆竞发启航 共筑鸿蒙生态”鸿蒙原生应用合作仪式在北京成功举办&#xff0c;近40个应用现场官宣启动鸿蒙原生应用开发。此次官宣启动开发的鸿蒙原生应用不仅包括教育、母婴、出行、医疗健康等多领域的知名应用&#xff0c;还有十多家企业内部办公应…

OverlayFS在嵌入式系统中的应用

文章目录 抛出问题基本概念使用场景OverlayFS的详细介绍框架目录合并修改文件删除文件添加文件小结 OverlayFS在嵌入式系统中的应用内核配置OverlayFS简单应用OverlayFS应用新思路 总结 环境介绍 硬件&#xff1a;T113平台 软件&#xff1a;Tina5.0 SDK&#xff08;使用的build…

【第3章】SpringBoot实战篇之登录接口(含JWT和拦截器)

文章目录 前言一、JWT1. 什么是JWT2. 使用场景3. 结构3.1 Header3.2 Payload3.3 Signature 4. 使用 二、案例1.引入库2.JwtUtils3. UserController14. ArticleController 三、拦截器1. 定义拦截器2. 注册拦截器 四、测试1. 登录2. 无token3. 有token4. 全局配置 总结 前言 前面…

485通讯网关

在工业自动化与智能化的浪潮中&#xff0c;数据的传输与交互显得尤为重要。作为这一领域的核心设备&#xff0c;485通讯网关凭借其卓越的性能和广泛的应用场景&#xff0c;成为了连接不同设备、不同协议之间数据转换和传输的桥梁。在众多485通讯网关中&#xff0c;HiWoo Box以其…

postman教程-10-使用cookie

领取资料&#xff0c;咨询答疑&#xff0c;请➕wei: June__Go 上一小节我们学习了Postman Authorization授权的几种方法&#xff0c;本小节我们讲解一下Postman 使用cookie的方法。 Postman 的 cookie 管理器使您能够查看和编辑与不同域关联的 cookie。您可以为域手动创建 c…

软件测试、测试模型、测试用例

软件开发的五个模型 瀑布模型&#xff08;Waterfall Model&#xff09; 瀑布模型是所有其他模型的基础框架&#xff0c;瀑布模型的每个阶段都只执行一次&#xff0c;因此是线性顺序进行的开发模式优点&#xff1a;强调开发的阶段性&#xff1b; 强调早期计划及需求调查&#…

【Python实战】使用postman测试flask api接口

cookie_demo.py # -*- coding: utf-8 -*- """ Time : 2024/5/28 17:14 Author : 娜年花开 File : cookie_demo.py Desc : 需求&#xff1a;用户需要先登陆&#xff0c;登陆之后&#xff0c;通过Cookie来判断是不是能够访问登录后的接口userinfo &quo…

TMS FNC WX Pack TMS软件分发的一组应用程序

TMS FNC WX Pack TMS软件分发的一组应用程序 TMS FNC WX Pack是由TMS软件分发的一组应用程序。这些活动是100%的跨平台和跨Frimorc&#xff0c;并在不同的应用程序中得到支持&#xff0c;如Web应用程序、Windows、Linux等。阿拉伯语视觉组件库。安装这些计算机的过程非常简单高…

第四讲 单片机STC89C52+RA8889代码移植范例(包含API接口)

本次介绍单片机STC89C52RA8889代码移植范例&#xff0c;该范例已将RA8889的API移植好了&#xff0c;下方提供下载地址。 硬件平台&#xff1a;89C52RA8889 采用SPI通信方式 (已测试通过&#xff09; 上一讲已经阐述RA8889移植到51单片机的基本方法&#xff0c;本讲增加了API…

【第一节】数据结构和算法绪论

目录 一、数据结构的起源与发展 二、什么是数据结构 三、数据的逻辑结构和存储结构 四、数据类型和数据结构 五、算法 六、算法与数据结构的关系 七、算法时间复杂度和空间复杂度 一、数据结构的起源与发展 数据结构的起源可以追溯至1968年。当时&#xff0c;美国的唐欧…

Spring Security 注册过滤器注意事项

前两天和小伙伴聊了 Spring SecurityJWT 实现无状态登录&#xff0c;然后有小伙伴反馈了一个问题&#xff0c;感觉这是一个我们平时写代码容易忽略的问题&#xff0c;写一篇文章和小伙伴们聊一聊。 一 问题复原 先来说问题吧&#xff0c;在 Spring SecurityJWT 登录中&#x…

C++入门5——C/C++动态内存管理(new与delete)

目录 1. 一图搞懂C/C的内存分布 2. 存在动态内存分配的原因 3. C语言中的动态内存管理方式 4. C内存管理方式 4.1 new/delete操作内置类型 4.2 new/delete操作自定义类型 1. 一图搞懂C/C的内存分布 说明&#xff1a; 1. 栈区&#xff08;stack&#xff09;&#xff1a;在…

【C语言】位段(结构体实现位段)

目录 一、位段的定义 二、位段的声明 三、位段的内存分配 四、位段在内存中的存储方式 五、位段的优点 六、位段的跨平台问题 七、位段的应用 八、位段使用的注意事项 一、位段的定义 信息的存取一般以字节为单位。实际上&#xff0c;有时存储一个信息不必用一个或多个字…

匠心独运,B 端系统 UI 演绎华章之美

匠心独运&#xff0c;B 端系统 UI 演绎华章之美

上位机图像处理和嵌入式模块部署(f103 mcu获取唯一id)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 对于stm32f103系列mcu来说&#xff0c;一般每一颗原厂的mcu&#xff0c;都会对应一个唯一的id。那这个id可以用来做什么用呢&#xff1f;个人认为&…

PX4 ROS2 真机

如果仿真跑通了。 真机遇到问题&#xff0c;可参考此文章。 ubuntu22 px4 1.14.3 ros2 humble 硬件接线。 先找两个usb - ttl串口&#xff0c;分别接到两台主机上&#xff0c;保证串口通信正常。 图中是个六合一的。浪费一天时间&#xff0c;发现是串口设置错误&#xff…

力扣 101. 对称二叉树

给你一个二叉树的根节点 root &#xff0c; 检查它是否轴对称。 /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*/ bool check(struct TreeNode* L,struct TreeNode* R){if(!L&…

socket网络编程——套接字地址结构

一、通用 socket 地址结构 socket 网络编程接口中表示 socket 地址的是结构体 sockaddr&#xff0c;其定义如下&#xff1a; 1. #include <bits/socket.h> 2. 3. struct sockaddr 4. { 5. sa_family_t sa_family; 6. char sa_data[14]; 7. }; sa_family 成员是地址族类型…