Css 简明教程

CSS - min-block-size Property

CSS 的 min-block-size 属性会根据元素的书写模式为元素的块设置最小尺寸(水平或垂直),这对应于 writing_mode 值所对应的 min-widthmin-height 属性。

CSS min-block-size property sets the minimum size, either horizontally or vertically, of an element’s block based on its writing mode, which corresponds to either the min-width or min-height property based on the writing_mode value.

对于垂直方向的书写模式, min-block-size 会决定最小宽度;对于水平方向的模式,它则决定最小高度。 min-inline-size 属性定义了另一个维度。

The min-block-size determines the minimum width for vertically oriented writing modes, and the minimum height for horizontally oriented mode.The min-inline-size property defines the other dimension.

Possible Values

min-block-size 属性接受与 min-heightmin-width 相同的值。

The min-block-size property accepts the same values as min-height and min-width.

Applies To

widthheight 相同。

Same as width and height.

Syntax

<length> Values

min-block-size: 100px;
min-block-size: 5em;

<percentage> Values

min-block-size: 10%;

Keyword Values

min-block-size: max-content;
min-block-size: min-content;
min-block-size: fit-content;
min-block-size: fit-content(20em);

CSS min-block-size - <length> Value

以下示例演示 min-block-size: 100px 属性将 div 元素的高度设置为了最少 100px−

The following example demonstrates the min-block-size: 100px property sets the height of the div element to a minimum of 100px −

<html>
<head>
<style>
   div {
      background-color: orange;
      border: 2px solid blue;
      min-block-size: 100px;
   }
</style>
</head>
<body>
   <div>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</body>
</html>

CSS min-block-size - max-content Value

以下示例演示 min-block-size: max-content 属性设置了适合其中内容的最小高度−

The following example demonstrates the min-block-size: max-content property sets minimum height that fits the content inside it −

<html>
<head>
<style>
   div {
      background-color: orange;
      border: 2px solid blue;
      min-block-size: max-content;
   }
</style>
</head>
<body>
   <div>Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</body>
</html>

CSS min-block-size - With Horizontal and Vertical Text

以下示例演示如何使用 min-block-size 属性来与 writing-modes 一起按照垂直方向显示文本−

The following example demonstrates how to use min-block-size property with writing-modes to display text in vertical direction −

<html>
<head>
<style>
   div {
      background-color: pink;
      border: 2px solid blue;
      min-block-size: 200px;
      writing-mode: vertical-rl;
   }
</style>
</head>
<body>
   <div>
      <p>CSS min-block-size</p>
   </div>
</body>
</html>