@neatui/css 4.2.4 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/GUIDE.md CHANGED
@@ -737,6 +737,47 @@ gap: 间距等级 (ss, sm, mm, ml, ll...)
737
737
  比例和偏移是同一个“高度模式”,一次只能选择一个;`cover / contain` 可以再与它
738
738
  组合。该语法不接受任意比例、任意百分比或响应式前缀。
739
739
 
740
+ 图上也可以用 `ui-fit` 写更完整的装入策略(含 `fill` / `none` / `down` 与锚点);
741
+ 若图已声明 `ui-fit`,则以图上的为准。
742
+
743
+ ### `ui-fit`:媒资装入
744
+
745
+ `ui-fit` 描述置换元素(`img` / `video` 等)相对已定尺寸容器的装入策略,对应
746
+ `object-fit`,可选锚点对应 `object-position`。与 `ui-cover`(造框)正交。
747
+
748
+ ```text
749
+ ui-fit="{mode} {anchor?}"
750
+ ```
751
+
752
+ `mode` 五选一:
753
+
754
+ | Token | 意图 | CSS |
755
+ |-------|------|-----|
756
+ | `cover` | 铺满,多出裁 | `object-fit: cover` |
757
+ | `contain` | 完整装入,可留白 | `object-fit: contain` |
758
+ | `fill` | 扯满,可变比 | `object-fit: fill` |
759
+ | `none` | 固有尺寸 | `object-fit: none` |
760
+ | `down` | 只缩不放 | `object-fit: scale-down` |
761
+
762
+ `anchor` 可选,复用 `ui-flex` 九宫格坐标:
763
+
764
+ ```text
765
+ lt ct rt
766
+ lm cm rm
767
+ lb cb rb
768
+ ```
769
+
770
+ ```html
771
+ <img ui-fit="cover" />
772
+ <img ui-fit="contain" />
773
+ <img ui-fit="cover lt" />
774
+ <img ui-fit="contain cm" />
775
+ <img ui-fit="down" />
776
+ ```
777
+
778
+ 不写 `ui-fit` 时保持浏览器默认;写在 `ui-cover` 框内且未声明时,由封面框默认
779
+ 按 `cover` 处理。该语法没有响应式前缀。
780
+
740
781
  ### `ui-omit`:1–9 行省略
741
782
 
742
783
  ```html
package/core/cover.scss CHANGED
@@ -17,17 +17,17 @@ $sz: no, xs, ss, sm, ms, mm, ml, ls, lm, ll, xl;
17
17
  background-position: center;
18
18
  background-repeat: no-repeat;
19
19
  }
20
- img {
20
+ // 封面框默认裁切铺满;图上显式 ui-fit 时由装入策略接管
21
+ img:not([ui-fit]) {
21
22
  object-fit: cover;
22
23
  }
23
-
24
24
  &[ui-cover~='cover'] {
25
- img {
25
+ img:not([ui-fit]) {
26
26
  object-fit: cover;
27
27
  }
28
28
  }
29
29
  &[ui-cover~='contain'] {
30
- img {
30
+ img:not([ui-fit]) {
31
31
  object-fit: contain;
32
32
  }
33
33
  }
package/core/fit.scss ADDED
@@ -0,0 +1,48 @@
1
+ // ui-fit:置换元素装入策略(object-fit)+ 可选九宫格锚点(object-position)
2
+ // 语法: ui-fit="{mode} {anchor?}"
3
+ // mode: cover | contain | fill | none | down
4
+ // anchor: lt lm lb ct cm cb rt rm rb(与 ui-flex 九宫格同词)
5
+
6
+ [ui-fit~='cover'] {
7
+ object-fit: cover;
8
+ }
9
+ [ui-fit~='contain'] {
10
+ object-fit: contain;
11
+ }
12
+ [ui-fit~='fill'] {
13
+ object-fit: fill;
14
+ }
15
+ [ui-fit~='none'] {
16
+ object-fit: none;
17
+ }
18
+ [ui-fit~='down'] {
19
+ object-fit: scale-down;
20
+ }
21
+
22
+ [ui-fit~='lt'] {
23
+ object-position: left top;
24
+ }
25
+ [ui-fit~='lm'] {
26
+ object-position: left center;
27
+ }
28
+ [ui-fit~='lb'] {
29
+ object-position: left bottom;
30
+ }
31
+ [ui-fit~='ct'] {
32
+ object-position: center top;
33
+ }
34
+ [ui-fit~='cm'] {
35
+ object-position: center center;
36
+ }
37
+ [ui-fit~='cb'] {
38
+ object-position: center bottom;
39
+ }
40
+ [ui-fit~='rt'] {
41
+ object-position: right top;
42
+ }
43
+ [ui-fit~='rm'] {
44
+ object-position: right center;
45
+ }
46
+ [ui-fit~='rb'] {
47
+ object-position: right bottom;
48
+ }
package/dist/neatui.css CHANGED
@@ -16440,10 +16440,10 @@ td[ui-col],th[ui-col]{
16440
16440
  top:0;
16441
16441
  width:100%;
16442
16442
  }
16443
- [ui-cover] img,[ui-cover][ui-cover~=cover] img{
16443
+ [ui-cover] img:not([ui-fit]),[ui-cover][ui-cover~=cover] img:not([ui-fit]){
16444
16444
  object-fit:cover;
16445
16445
  }
16446
- [ui-cover][ui-cover~=contain] img{
16446
+ [ui-cover][ui-cover~=contain] img:not([ui-fit]){
16447
16447
  object-fit:contain;
16448
16448
  }
16449
16449
  [ui-cover][ui-cover~="1:1"]{
@@ -16570,6 +16570,62 @@ td[ui-col],th[ui-col]{
16570
16570
  padding-top:50%;
16571
16571
  }
16572
16572
 
16573
+ [ui-fit~=cover]{
16574
+ object-fit:cover;
16575
+ }
16576
+
16577
+ [ui-fit~=contain]{
16578
+ object-fit:contain;
16579
+ }
16580
+
16581
+ [ui-fit~=fill]{
16582
+ object-fit:fill;
16583
+ }
16584
+
16585
+ [ui-fit~=none]{
16586
+ object-fit:none;
16587
+ }
16588
+
16589
+ [ui-fit~=down]{
16590
+ object-fit:scale-down;
16591
+ }
16592
+
16593
+ [ui-fit~=lt]{
16594
+ object-position:left top;
16595
+ }
16596
+
16597
+ [ui-fit~=lm]{
16598
+ object-position:left center;
16599
+ }
16600
+
16601
+ [ui-fit~=lb]{
16602
+ object-position:left bottom;
16603
+ }
16604
+
16605
+ [ui-fit~=ct]{
16606
+ object-position:center top;
16607
+ }
16608
+
16609
+ [ui-fit~=cm]{
16610
+ object-position:center center;
16611
+ }
16612
+
16613
+ [ui-fit~=cb]{
16614
+ object-position:center bottom;
16615
+ }
16616
+
16617
+ [ui-fit~=rt]{
16618
+ object-position:right top;
16619
+ }
16620
+
16621
+ [ui-fit~=rm]{
16622
+ object-position:right center;
16623
+ }
16624
+
16625
+ [ui-fit~=rb]{
16626
+ object-position:right bottom;
16627
+ }
16628
+
16573
16629
  .ux-none,.ux-none *,.ux-none-sub>*,.ux-none-sub>* *{
16574
16630
  cursor:pointer;
16575
16631
  user-select:none;