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 =
auto |
<box-size>
<box-size> =
<length-percentage> |
stretch |
contain |
min-content |
max-content |
fit-content |
fit-content( ) |
calc-size( )
<length-percentage> =
<length> |
<percentage>
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 Module Level 1> # propdef-block-size> |
Compatibilidade com navegadores
See also
- As propriedades:
widthandheight writing-mode