块大小 | block-size
block-size
这是一种实验技术
由于该技术的规格不稳定,请查看各种浏览器的兼容性表格以供使用。还要注意,随着规范的变化,实验技术的语法和行为在未来版本的浏览器中可能会发生变化。
block-size
定义一个元素的块的水平或垂直尺寸,这取决于它的写入模式。其对应于任一width
或height
属性,这取决于的值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 type | discrete |
规范顺序 | the unique non-ambiguous order defined by the formal grammar |
句法
取值
block-size
属性的值有width
和height
。
形式语法
<'width'>
例
HTML
<p class="exampleText">Example text</p>
CSS
.exampleText {
writing-mode: vertical-rl;
background-color: yellow;
block-size: 200px;
}
规格
Specification | Status | Comment |
---|---|---|
CSS Logical Properties Level 1The definition of 'block-size' in that specification. | Editor's Draft | Initial definition |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | No support | 41.0 (41.0)1 | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | No support | 41.0 (41.0)1 | No support | No support | No support |