在线文档教程
CSS
逻辑属性 | Logical Properties

块大小 | block-size

block-size

这是一种实验技术

由于该技术的规格不稳定,请查看各种浏览器的兼容性表格以供使用。还要注意,随着规范的变化,实验技术的语法和行为在未来版本的浏览器中可能会发生变化。

block-size 定义一个元素的块的水平或垂直尺寸,这取决于它的写入模式。其对应于任一widthheight属性,这取决于的值writing-mode

/* <length> values */ block-size: 300px; block-size: 25em; /* <percentage> values */ block-size: 75%; /* Keyword values */ block-size: 25em border-box; block-size: 75% content-box; block-size: max-content; block-size: min-content; block-size: available; block-size: fit-content; block-size: auto; /* Global values */ block-size: inherit; block-size: initial; block-size: unset;

如果书写模式是垂直定向的,则其值block-size与元素的宽度有关; 否则,它涉及元素的高度。一个相关的属性是inline-size,它定义了元素的另一个维度。

初始值auto
应用于same as width and height
是否继承no
百分比block-size of containing block
适用媒体visual
计算值same as width and height
Animation typediscrete
规范顺序the unique non-ambiguous order defined by the formal grammar

句法

取值

block-size属性的值有widthheight

形式语法

<'width'>

HTML

<p class="exampleText">Example text</p>

CSS

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

规格

SpecificationStatusComment
CSS Logical Properties Level 1The definition of 'block-size' in that specification.Editor's DraftInitial definition

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic supportNo support41.0 (41.0)1No supportNo supportNo support

FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic supportNo support41.0 (41.0)1No supportNo supportNo support