`inline-size` CSS property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

The **inline-size** CSS property defines the size of an element's block along the inline axis. If the {{cssxref("writing-mode")}} is horizontal, it corresponds to the {{cssxref("width")}}; if the writing mode is vertical, it corresponds to the {{cssxref("height")}}. A related property is {{cssxref("block-size")}}, which defines the other dimension of the element.

{{InteractiveExample("CSS Demo: inline-size")}}

css interactive-example-choice
inline-size: 150px;
writing-mode: horizontal-tb;
css interactive-example-choice
inline-size: 150px;
writing-mode: vertical-rl;
css interactive-example-choice
inline-size: auto;
writing-mode: horizontal-tb;
css interactive-example-choice
inline-size: auto;
writing-mode: vertical-lr;
html interactive-example
<section class="default-example" id="default-example">
  <div class="transition-all" id="example-element">
    This is a box where you can change the inline-size.
  </div>
</section>
css interactive-example
#example-element {
  display: flex;
  flex-direction: column;
  background-color: #5b6dcd;
  height: 80%;
  justify-content: center;
  color: white;
}

Syntax

css
/* <length> values */
inline-size: 300px;
inline-size: 25em;
inline-size: anchor-size(width);
inline-size: anchor-size(--my-anchor inline);

/* <percentage> values */
inline-size: 75%;

/* Keyword values */
inline-size: max-content;
inline-size: min-content;
inline-size: fit-content;
inline-size: fit-content(20em);
inline-size: auto;

/* Global values */
inline-size: inherit;
inline-size: initial;
inline-size: revert;
inline-size: revert-layer;
inline-size: unset;

Values

The inline-size property takes the same values as the {{cssxref("width")}} and {{cssxref("height")}} properties.

Formal definition

{{cssinfo}}

Formal syntax

{{csssyntax}}

Examples

Setting inline size in pixels

HTML

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

CSS

css
.exampleText {
  writing-mode: vertical-rl;
  background-color: yellow;
  inline-size: 110px;
}

Result

{{EmbedLiveSample("Setting_inline_size_in_pixels")}}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • The mapped physical properties: {{cssxref("width")}} and {{cssxref("height")}}
  • {{cssxref("writing-mode")}}