Back to Amis

Top / Right / Bottom / Left

packages/amis-ui/scss/helper/layout/_top-right-bottom-left.md

6.13.06.8 KB
Original Source

用来控制位置的样式集。

ClassProperties
inset-0top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
-inset-0top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
inset-y-0top: 0px;
bottom: 0px;
inset-x-0right: 0px;
left: 0px;
-inset-y-0top: 0px;
bottom: 0px;
-inset-x-0right: 0px;
left: 0px;
top-0top: 0px;
right-0right: 0px;
bottom-0bottom: 0px;
left-0left: 0px;
-top-0top: 0px;
-right-0right: 0px;
-bottom-0bottom: 0px;
-left-0left: 0px;
inset-0.5top: 0.125rem;
right: 0.125rem;
bottom: 0.125rem;
left: 0.125rem;
-inset-0.5top: -0.125rem;
right: -0.125rem;
bottom: -0.125rem;
left: -0.125rem;
inset-y-0.5top: 0.125rem;
bottom: 0.125rem;
inset-x-0.5right: 0.125rem;
left: 0.125rem;
-inset-y-0.5top: -0.125rem;
bottom: -0.125rem;
-inset-x-0.5right: -0.125rem;
left: -0.125rem;
top-0.5top: 0.125rem;
right-0.5right: 0.125rem;
bottom-0.5bottom: 0.125rem;
left-0.5left: 0.125rem;
-top-0.5top: -0.125rem;
-right-0.5right: -0.125rem;
-bottom-0.5bottom: -0.125rem;
-left-0.5left: -0.125rem;

按以下尺寸表依次类推

尺寸大小
00
0.50.125rem;
10.25rem
1.50.375rem
1.50.375rem
20.5rem
2.50.625rem
30.75rem
3.50.875rem
41rem
51.25rem
61.5rem
71.75rem
82rem
92.25rem
102.5rem
112.75rem
123rem
143.5rem
164rem
205rem
246rem
287rem
328rem
369rem
4010rem
4411rem
4812rem
5213rem
5614rem
6015rem
6416rem
6817rem
7218rem
7619rem
8020rem
9624rem
autoauto
1/250%
1/333.333333%
2/366.666667%
1/425%;
2/450%;
3/475%;
full100%;
px0.0625rem(1px)

用法

结合 relative 和 absolute 定位 和位置样式 {top|right|bottom|left|inset}-xxx,可以很方便的实现各种组件布局。

html
<div class="grid grid-cols-4 m:grid-cols-2 gap-4">

<!-- Span top edge -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute inset-x-0 top-0 h-16 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">1</div>
</div>

<!-- Span right edge -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute inset-y-0 right-0 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">2</div>
</div>

<!-- Span bottom edge -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute inset-x-0 bottom-0 h-16 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">3</div>
</div>

<!-- Span left edge -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute inset-y-0 left-0 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">4</div>
</div>

<!-- Fill entire parent -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute inset-0 bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">5</div>
</div>

<!-- Pin to top left corner -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute left-0 top-0 h-16 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">6</div>
</div>

<!-- Pin to top right corner -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute top-0 right-0 h-16 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">7</div>
</div>

<!-- Pin to bottom right corner -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute bottom-0 right-0 h-16 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">8</div>
</div>

<!-- Pin to bottom left corner -->
<div class="relative h-32 w-32 ... bg-blue-500">
  <div class="absolute bottom-0 left-0 h-16 w-16 ... bg-red-500 text-white font-extrabold text-2xl flex items-center justify-center">9</div>
</div>

</div>

响应式设计

支持通过添加设备前缀 m: 或者 pc: 来分别针对「手机端」或者「pc端」设置样式,更多说明请前往「响应式设计」

状态前缀

不支持「状态前缀」,有需求请提 issue