min-block-size

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

CSS 属性 min-block-size 根据元素的书写模式定义了元素区块的横向或纵向最小尺寸。根据 writing-mode 的值,此属性对应于 min-widthmin-height 属性。

若为纵向书写模式,则 min-block-size 的值对应于元素的最小宽度;否则对应于元素的最小高度。与此相关的属性为 min-inline-size,此属性定义了元素另一方向的尺度。

尝试一下

min-block-size: 150px;
writing-mode: horizontal-tb;
min-block-size: 150px;
writing-mode: vertical-rl;
min-block-size: 20px;
writing-mode: horizontal-tb;
min-block-size: 15em;
writing-mode: vertical-lr;
This is a box where you can change the minimum block size.
If there is more content than the minimum the box will grow in the block dimension as needed by the content.
#example-element {
  display: flex;
  flex-direction: column;
  background-color: #5b6dcd;
  justify-content: center;
  color: #ffffff;
}

语法

css
/*  值 */
min-block-size: 100px;
min-block-size: 5em;

/*  值 */
min-block-size: 10%;

/* 关键词值 */
min-block-size: max-content;
min-block-size: min-content;
min-block-size: fit-content(20em);

/* 全局值 */
min-block-size: inherit;
min-block-size: initial;
min-block-size: revert;
min-block-size: revert-layer;
min-block-size: unset;

取值

min-block-size 属性的取值与 min-widthmin-height 属性相同。

形式定义

初始值0
适用元素same as width and height
是否是继承属性
Percentagesblock-size of containing block
计算值same as min-width and min-height
动画类型a length, percentage or calc();

形式语法

min-block-size = 
<'min-width'>

=
auto |
|
min-content |
max-content |
fit-content( ) |
|


=
|


=
calc-size( , )

=
anchor-size( [ || ]? , ? )

=
|
|
any |


=
[ [ '+' | '-' ] ]*

=


=
width |
height |
block |
inline |
self-block |
self-inline

=
[ [ '*' | / ] ]*

=
|
|
|
|
( )

=
e |
pi |
infinity |
-infinity |
NaN

示例

为竖排文本设置最小块向尺寸

HTML

html

示例文本

CSS

css
.exampleText {
  writing-mode: vertical-rl;
  background-color: yellow;
  min-block-size: 200px;
}

结果

规范

Specification
CSS Logical Properties and Values Level 1
# propdef-min-block-size
CSS Box Sizing Module Level 4
# sizing-values

浏览器兼容性

参见