@DanCWilson
At a high level...
translateX(-20px)
rotate(25deg)
scale(.5)
skewY(-12deg)
rotateX(30deg)
We will get into several aspects of transform
See the Pen Transforms: Stacking Contexts & Containing Blocks by Dan Wilson (@danwilson) on CodePen.
transition
and animation
)
input {
transform: scale(1);
transition: transform 200ms ease-in-out;
animation: enter 175ms 0ms 1 ease-out both;
}
input:disabled {
transform: scale(.9)
}
@keyframes enter {
from {
scale(0);
}
}
transform-origin
50% 50%
transform-origin
rotateSee the Pen Animating transform-origin by Dan Wilson (@danwilson) on CodePen.
transform-origin
scaleSee the Pen Animating transform-origin (scale) by Dan Wilson (@danwilson) on CodePen.
transform-origin
skewSee the Pen Animating transform-origin (skewX) by Dan Wilson (@danwilson) on CodePen.
will-change
will-change
will-change
transform
propertySee the Pen Visual Reference: Transform Coordinate Systems by Dan Wilson (@danwilson) on CodePen.
See the Pen Button Example: CSSDC by Dan Wilson (@danwilson) on CodePen.
button {
transform: translateY(-150%)
}
button:hover {
transform: scale(.8)
}
button:active {
transform: rotate(-5deg)
}
translate
, rotate
, & scale
translate: X Y
rotate: <angle>
scale: X Y
transform
propertytranslate
rotate
scale
transform
Wow, It’s so impressive what all options we have with transforms, and I was really getting excited about the prospect of these individual properties. But they seem a bit more limited in their viability than I expected, and it’s disappointing to hear they are only in Chrome Canary. Dan, isn’t there a solution to use today that has all the power of using as many transform combinations as I want - and in the order I want them - but also allows me the ability to change individual function values when I want them without having to know the state of all the others? And wait, am I really sure this is what I am thinking, or are you just allowing some time to rest your voice?
:root {
--primary: #3489ab;
}
.branding {
color: var(--primary);
}
.branding {
--primary: #3489ab;
color: var(--primary);
}
.branding.subdued {
--primary: #24699b;
}
.logo {
--translate-x: 80px;
--scale: .5;
transform:
translateX(var(--translate-x))
scale(var(--scale));
}
.logo.secondary {
--scale: .75;
/* transform: translateX(80px) scale(.75)*/
}
.logo.tertiary {
--translate-x: 20px;
/* transform: translateX(20px) scale(.5)*/
}
.logo.fourthiary {
--translate-x: 10px;
--scale: .4;
/* transform: translateX(10px) scale(.4)*/
}
.logo {
--translate-x: 80px;
--scale: .5;
--rotate: 10deg;
--scale-end: .75;
transform:
translateX(var(--translate-x))
scale(var(--scale))
rotate(var(--rotate))
scale(var(--scale-end));
}
.logo {
--translate-x: 80px;
--scale: .5;
transform:
translateX(var(--translate-x))
scale(var(--scale));
transition: transform 200ms ease-in-out;
}
See the Pen Button Example: CSSDC by Dan Wilson (@danwilson) on CodePen.
background
, animation
, box-shadow
, filter
--background-topmost
or --shape-animation-state
See the Pen Pause Independent Animations with CSS Variables by Dan Wilson (@danwilson) on CodePen.
element.style.setProperty('--var', 5)
See the Pen CSS Variables + Transform = Individual Properties (with Inputs) by Dan Wilson (@danwilson) on CodePen.
transform
and more from JScomposite
See the Pen Visual Reference: 3D Transform Functions by Dan Wilson (@danwilson) on CodePen.
perspective
transform
for simple casesSee the Pen Visual Reference: Perspective (Property vs. Transform Function) by Dan Wilson (@danwilson) on CodePen.
perspective-origin
See the Pen Perspective Origin by Dan Wilson (@danwilson) on CodePen.
transform-style
See the Pen Visual Reference: Transform-Style by Dan Wilson (@danwilson) on CodePen.
transform: rotateX(39deg)
and it doesn’t look right:See the Pen Pyramid from Cube by Dan Wilson (@danwilson) on CodePen.
See the Pen Pixel Art Animated with Custom Properties by Dan Wilson (@danwilson) on CodePen.
.moving-picture {
transform: rotate(var(--angle));
animation: move-it 350ms ease both;
}
@keyframes move-it {
0% {
--angle: 0deg;
}
100% {
--angle: 100deg;
}
}
transform
aloneSee the Pen Spin a lot: #SZR #DZY by Dan Wilson (@danwilson) on CodePen.