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 janeiro de 2020.
* Some parts of this feature may have varying levels of support.
Experimental: Esta é uma tecnologia experimental
Verifique a tabela de compatibilidade entre Navegadores cuidadosamente antes de usar essa funcionalidade em produção.
A propriedade CSS block-size define o tamanho horizontal ou vertical de um elemento bloco. Corresponde à propriedade width ou height, dependendo do valor do writing-mode.
Experimente
block-size: 150px; writing-mode: horizontal-tb; block-size: 150px; writing-mode: vertical-rl; block-size: auto; writing-mode: horizontal-tb; block-size: auto; writing-mode: vertical-lr; <section class="default-example" id="default-example"> <div class="transition-all" id="example-element"> This is a box where you can change the block-size. </div> </section> #example-element { display: flex; flex-direction: column; background-color: #5b6dcd; justify-content: center; color: #ffffff; } Sintaxe
/* valores <length> */ block-size: 300px; block-size: 25em; /* valores <percentage> */ block-size: 75%; /* valores de Keyword */ 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; /* valores globais */ block-size: inherit; block-size: initial; block-size: unset; Se o modo de escrita está orientado verticalmente, o valor do block-size refere-se à largura do elemento; senão, refere-se à altura do elemento. Uma propriedade relacionada é inline-size, que define as outras dimensões do elemento.
Valores
A propriedade block-size leva os mesmos valores que as propriedades width e height.
Definição formal
| Initial value | auto |
|---|---|
| Aplica-se a | same as width and height |
| Inherited | não |
| Percentages | block-size of containing block |
| Computed value | same as width and height |
| Animation type | a length, percentage or calc(); |
Sintaxe formal
block-size =
<'width'>
<width> =
auto |
<length-percentage [0,∞]> |
min-content |
max-content |
fit-content( <length-percentage [0,∞]> ) |
<calc-size()> |
<anchor-size()> |
stretch |
fit-content |
contain
<length-percentage> =
<length> |
<percentage>
<calc-size()> =
calc-size( <calc-size-basis> , <calc-sum> )
<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
<calc-size-basis> =
<size-keyword> |
<calc-size()> |
any |
<calc-sum>
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<anchor-name> =
<dashed-ident>
<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline
<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
Exemplo
>HTML
<p class="exampleText">Example text</p> CSS
.exampleText { writing-mode: vertical-rl; background-color: yellow; block-size: 200px; } Especificações
| Specification |
|---|
| CSS Logical Properties and Values Level 1> # dimension-properties> |
| CSS Box Sizing Module Level 4> # sizing-values> |
Compatibilidade com navegadores
Loading…
See also
- As propriedades:
widthandheight writing-mode