CKTIS / CSS
skewX(): horizontal shear, not rotation
Shift each point horizontally according to its height while keeping the original layout box.
Version: CSS Modules
Syntax
transform: skewX(45deg);The transform function skewX() takes one angle, or a unitless zero. Relative to the chosen origin, the coordinate rule is x′ = x + y × tan(a), while y stays unchanged. A positive 45-degree angle therefore shifts a point with positive y towards positive x. This is a shear, not a rigid rotation: angles and lengths can change.
The pivot comes from transform-origin. Using the ordinary box’s default center gives a different placement from using its top-left corner, even though the shear matrix has the same coefficients. Near an odd multiple of 90 degrees the tangent grows extremely large, so such values are unsuitable for a stable, readable interface. The transform can change visual overflow without reserving a correspondingly wider space in normal layout.
The example fixes the origin at zero and transforms the local point 10,20. Positive 45 degrees gives 30,20, while negative 45 degrees gives -10,20. The 100×50px box has visible axis-aligned bounds of 150×50px but still occupies a 100×50px layout box. The syntax checks distinguish an invalid nonzero angle without a unit from valid unitless zero.
Examples
const box = document.createElement('div');
box.style.cssText = 'width:100px;height:50px;transform-origin:0 0';
document.body.append(box);
function point(value) {
box.style.transform = value;
const p = new DOMMatrix(getComputedStyle(box).transform).transformPoint(new DOMPoint(10,20));
return [p.x,p.y].map(n => Number(n.toFixed(6))).join(',');
}
console.log('+45:', point('skewX(45deg)'));
console.log('-45:', point('skewX(-45deg)'));
box.style.transform = 'skewX(45deg)';
const r = box.getBoundingClientRect();
console.log('visual:', Math.round(r.width), Math.round(r.height));
console.log('layout:', box.offsetWidth, box.offsetHeight);
console.log('unitless nonzero:', CSS.supports('transform','skewX(45)'));
console.log('unitless zero:', CSS.supports('transform','skewX(0)'));
box.remove();Result
+45: 30,20 -45: -10,20 visual: 150 50 layout: 100 50 unitless nonzero: false unitless zero: true
Coordinates come from the browser’s computed matrix and are rounded to six decimals. The bounding rectangle is measured separately; the example does not rely on judging a screenshot or on undefined behavior at a tangent pole.