/*!markdown --- title: Top / Right / Bottom / Left --- 用来控制位置的样式集。 | Class | Properties | | ------------ | --------------------------------------------------------------------------------- | | inset-0 | top: 0px;
right: 0px;
bottom: 0px;
left: 0px; | | -inset-0 | top: 0px;
right: 0px;
bottom: 0px;
left: 0px; | | inset-y-0 | top: 0px;
bottom: 0px; | | inset-x-0 | right: 0px;
left: 0px; | | -inset-y-0 | top: 0px;
bottom: 0px; | | -inset-x-0 | right: 0px;
left: 0px; | | top-0 | top: 0px; | | right-0 | right: 0px; | | bottom-0 | bottom: 0px; | | left-0 | left: 0px; | | -top-0 | top: 0px; | | -right-0 | right: 0px; | | -bottom-0 | bottom: 0px; | | -left-0 | left: 0px; | | inset-0.5 | top: 0.125rem;
right: 0.125rem;
bottom: 0.125rem;
left: 0.125rem; | | -inset-0.5 | top: -0.125rem;
right: -0.125rem;
bottom: -0.125rem;
left: -0.125rem; | | inset-y-0.5 | top: 0.125rem;
bottom: 0.125rem; | | inset-x-0.5 | right: 0.125rem;
left: 0.125rem; | | -inset-y-0.5 | top: -0.125rem;
bottom: -0.125rem; | | -inset-x-0.5 | right: -0.125rem;
left: -0.125rem; | | top-0.5 | top: 0.125rem; | | right-0.5 | right: 0.125rem; | | bottom-0.5 | bottom: 0.125rem; | | left-0.5 | left: 0.125rem; | | -top-0.5 | top: -0.125rem; | | -right-0.5 | right: -0.125rem; | | -bottom-0.5 | bottom: -0.125rem; | | -left-0.5 | left: -0.125rem; | 按以下尺寸表依次类推 | 尺寸 | 大小 | | ---- | -------------- | | 0 | 0 | | 0.5 | 0.125rem; | | 1 | 0.25rem | | 1.5 | 0.375rem | | 1.5 | 0.375rem | | 2 | 0.5rem | | 2.5 | 0.625rem | | 3 | 0.75rem | | 3.5 | 0.875rem | | 4 | 1rem | | 5 | 1.25rem | | 6 | 1.5rem | | 7 | 1.75rem | | 8 | 2rem | | 9 | 2.25rem | | 10 | 2.5rem | | 11 | 2.75rem | | 12 | 3rem | | 14 | 3.5rem | | 16 | 4rem | | 20 | 5rem | | 24 | 6rem | | 28 | 7rem | | 32 | 8rem | | 36 | 9rem | | 40 | 10rem | | 44 | 11rem | | 48 | 12rem | | 52 | 13rem | | 56 | 14rem | | 60 | 15rem | | 64 | 16rem | | 68 | 17rem | | 72 | 18rem | | 76 | 19rem | | 80 | 20rem | | 96 | 24rem | | auto | auto | | 1/2 | 50% | | 1/3 | 33.333333% | | 2/3 | 66.666667% | | 1/4 | 25%; | | 2/4 | 50%; | | 3/4 | 75%; | | full | 100%; | | px | 0.0625rem(1px) | ## 用法 结合 relative 和 absolute 定位 和位置样式 `{top|right|bottom|left|inset}-xxx`,可以很方便的实现各种组件布局。 ```html
1
2
3
4
5
6
7
8
9
``` ## 响应式设计 支持通过添加设备前缀 `m:` 或者 `pc:` 来分别针对「手机端」或者「pc端」设置样式,更多说明请前往[「响应式设计」](../../../docs/style/responsive-design.md)。 ## 状态前缀 不支持[「状态前缀」](../../../docs/style/state.md),有需求请提 [issue](https://github.com/baidu/amis/issues)。 */ @mixin make-single-position( $selector, $direction, $name, $value, $prefix: '.' ) { #{$prefix}#{'' + selector-escape($selector + '-' + $name) } { #{$direction}: $value; } } @mixin make-single-positions($direction, $map: $inset, $prefix: '.') { @each $name, $value in $map { @include make-single-position( $direction, $direction, $name, $value, $prefix ); } @each $name, $value in $map { @if (type-of($value) == 'number') { @include make-single-position( #{'-' + $direction}, $direction, $name, ($value * -1), $prefix ); } } } @mixin make-inset-positions($map: $inset, $prefix: '.') { @each $name, $value in $map { #{$prefix}#{selector-escape('inset-' + $name) } { top: $value; right: $value; bottom: $value; left: $value; } } @each $name, $value in $map { @if (type-of($value) == 'number') { #{$prefix}#{selector-escape('-inset-' + $name) } { top: $value * -1; right: $value * -1; bottom: $value * -1; left: $value * -1; } } } } @mixin make-inset-x-positions($map: $inset, $prefix: '.') { @each $name, $value in $map { #{$prefix}#{selector-escape('inset-x-' + $name) } { right: $value; left: $value; } } @each $name, $value in $map { @if (type-of($value) == 'number') { #{$prefix}#{selector-escape('-inset-x-' + $name) } { right: $value * -1; left: $value * -1; } } } } @mixin make-inset-y-positions($map: $inset, $prefix: '.') { @each $name, $value in $map { #{$prefix}#{selector-escape('inset-y-' + $name) } { top: $value; bottom: $value; } } @each $name, $value in $map { @if (type-of($value) == 'number') { #{$prefix}#{selector-escape('-inset-y-' + $name) } { top: $value * -1; bottom: $value * -1; } } } } @include make-single-positions('top'); @include make-single-positions('right'); @include make-single-positions('bottom'); @include make-single-positions('left'); @include make-inset-positions(); @include make-inset-x-positions(); @include make-inset-y-positions(); @each $deivce in map-keys($devices) { @include media-device($deivce) { @include make-single-positions( 'top', $inset, '.' + selector-escape($deivce + ':') ); @include make-single-positions( 'right', $inset, '.' + selector-escape($deivce + ':') ); @include make-single-positions( 'bottom', $inset, '.' + selector-escape($deivce + ':') ); @include make-single-positions( 'left', $inset, '.' + selector-escape($deivce + ':') ); @include make-inset-positions($inset, '.' + selector-escape($deivce + ':')); @include make-inset-x-positions( $inset, '.' + selector-escape($deivce + ':') ); @include make-inset-y-positions( $inset, '.' + selector-escape($deivce + ':') ); } }