CKTIS / CSS
CSS-Eigenschaft `rotate`
Die Eigenschaft `rotate` beschreibt eine unabhängige Rotationstransformation: Ein einzelner Winkel wie `90deg` rotiert in 2D, während eine Achsenform mit `x`, `y` oder `z` eine 3D-Rotation um einen Vektor durch den Transformationsursprung beschreibt.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
none | <angle> | [ x | y | z | <number>{3} ] && <angle>Die Eigenschaft rotate beschreibt eine unabhängige Rotationstransformation: Ein einzelner Winkel wie 90deg rotiert in 2D, während eine Achsenform mit x, y oder z eine 3D-Rotation um einen Vektor durch den Transformationsursprung beschreibt.
Das Beispiel wendet rotate:90deg auf ein Rechteck von 40 mal 20 an; seine gedrehte Begrenzungsbox liegt bei 110,40 und ist 20 mal 40 groß, während ein zweites Rechteck mit transform:none 40 mal 20 bleibt.
Grammatik: none | <angle> | [ x | y | z | <number>{3} ] && <angle>.
Einzeltransformationen werden in der Reihenfolge translate, rotate, scale und erst danach transform zusammengesetzt. Ein Achsenvektor der Länge null bewirkt keine Rotation; 0deg richtet dennoch Transformation und Stapelkontext ein, none dagegen nicht, was die Einfassung positionierter Nachfahren beeinflusst.
Beispiele
<!doctype html><meta charset="utf-8"><style>html,body{margin:0}.box{position:absolute;width:40px;height:20px;top:50px;transform-origin:center}#turned{left:100px;rotate:90deg}#plain{left:200px;rotate:none}</style><i id="turned" class="box"></i><i id="plain" class="box"></i><pre id="result"></pre><script>const shape=e=>{const r=e.getBoundingClientRect();return[Math.round(r.left),Math.round(r.top),Math.round(r.width),Math.round(r.height)]},a=shape(turned),b=shape(plain),s=getComputedStyle(turned);if(a.join(',')!=='110,40,20,40'||b.join(',')!=='200,50,40,20'||s.rotate!=='90deg'||s.transform!=='none')throw new Error('rotate mismatch '+[a,b,s.rotate,s.transform]);result.textContent='rotated='+a.join(',')+'; plain='+b.join(',')+'; rotate='+s.rotate+'; transform='+s.transform;</script>Ergebnis
rotated=110,40,20,40; plain=200,50,40,20; rotate=90deg; transform=none
Das Beispiel wendet `rotate:90deg` auf ein Rechteck von 40 mal 20 an; seine gedrehte Begrenzungsbox liegt bei 110,40 und ist 20 mal 40 groß, während ein zweites Rechteck mit `transform:none` 40 mal 20 bleibt.