DEV Community

Kai Oswald
Kai Oswald

Posted on

5 1

CSS Transform/Detransform

When you only want the transform on the parent element you'll want to apply the negative transform on the child.
This is especially useful for skew and rotate.

.container {
    transform: skewX(15deg)
}
.container > * {
    transform: skewX(-15deg);
}
<div class="container">
    <div class="content">
        This content is not transformed
    </div>
</div>

Now with CSS variables. This uses calc() to negate the value.

:root {
    --value: 15deg;
}
.container {
    transform: skewX(var(--value))
}
.container > * {
    transform: skewX(calc(-1 * var(--value)));
}

Adding media-queries to handle different screen sizes with different values (rotating an element can make it really big depending on its width).

:root {
    --value: 15deg;
}

@media screen and (min-width: 1440px) {
    :root {
        --value: 5deg;
    }
}

.container {
    transform: skewX(var(--value))
}
.container > * {
    transform: skewX(calc(-1 * var(--value)));
}

Another example using SkewY on a full-width container

Image of Stellar post

From Hackathon to Funded - Stellar Dev Diaries Ep. 1 πŸŽ₯

Ever wondered what it takes to go from idea to funding? In episode 1 of the Stellar Dev Diaries, we hear how the Freelii team did just that. Check it out and follow along to see the rest of their dev journey!

Watch the video

Top comments (0)

PulumiUP 2025 image

PulumiUP 2025: Cloud Innovation Starts Here

Get inspired by experts at PulumiUP. Discover the latest in platform engineering, IaC, and DevOps. Keynote, demos, panel, and Q&A with Pulumi engineers.

Register Now

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay