Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

transform-box — the transformation reference box

transform-box selects the reference rectangle for transformations and their origin. It affects percentage translations and the interpretation of transform-origin in CSS and SVG.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

transform-box: content-box | border-box | fill-box | stroke-box | view-box;

transform-box selects the reference box for transform and transform-origin; it does not itself apply a transformation. Horizontal percentage translations use its width; vertical ones use its height. Initially view-box, it is not inherited, applies to transformable elements, and animates discretely.

content-box selects the content area; border-box also includes padding and borders, but not margins. fill-box selects the object bounding box, stroke-box includes the stroke, and view-box uses the nearest SVG viewport; with viewBox, it uses that coordinate system's origin and the specified width and height.

For elements with a CSS layout box, fill-box acts as content-box, while stroke-box and view-box act as border-box. For SVG elements without such a box, content-box acts as fill-box, and border-box acts as stroke-box.

In the example, translateX(100%) moves the boxes by 100px and 130px respectively: the second calculation includes padding and borders on both sides.

Examples

<!doctype html>
<meta charset="utf-8">
<title>transform-box</title>
<style>
  .box {
    box-sizing: content-box;
    width: 100px;
    height: 20px;
    padding: 10px;
    border: 5px solid navy;
    margin: 10px 0;
    background: lightblue;
    transform: translateX(100%);
  }
  .content { transform-box: content-box; }
  .border { transform-box: border-box; }
</style>
<div class="box content">content-box</div>
<div class="box border">border-box</div>

Result

content-box: translateX = 100px
border-box: translateX = 130px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources