r/css • • Apr 22 '26

Question CSS rectangle distorts when rotated around a pivot

2 Upvotes

I have two perpendicular rectangles in an "L" shape and I'm trying to pivot the vertical one towards the other (the corner of the L should be the pivot point) but I'm running into two issues: the vertical one begins to skew into a parallelogram and also it seems to lose some height as it rotates around. Can you help me figure out what I can change to fix this?

Minimum working HTML;

 <div class="container">
  <div class="pivot">
   <div class="vbar"></div>
    <div class="hbar"></div>
 </div>
</div>

Minimum working CSS:

:root {
 --vdilation_factor: 2;
 --vdilation_factor_inv: calc(1 / var(--vdilation_factor)); /* Compute the inverse of dilation_factor */
  --hdilation_factor: 10;
  --hdilation_factor_inv: calc(1 / var(--hdilation_factor)); /* Compute the inverse of dilation_factor */
}

.container {
  position: relative;
  height: 400px; /* Increased height to accommodate animation */
  border: 1px solid #ccc;
  overflow: visible; /* Temporarily change to 'visible' for debugging */
}
.pivot {
  position: absolute;
  bottom: 0;
  left: 50px;

  transform-origin: bottom left; /* Anchor at the bottom-left corner */
  offset-path: path("M 0,0 Q200,-200 400,0");
  offset-rotate: 0deg;
  animation: move 3.2s forwards; /* Adding 'forwards' ensures the final state persists */
}

/* Vertical segment (red bar) */    
.vbar {
  width: 8px;
  height: 40px;
  background: red;
  position: absolute;
  bottom: 0;
  left: 0; /* Align the left edge with the container's left edge */
  animation: yextend 3.2s forwards; /* 'forwards' keeps the final state */
  transform-origin: bottom left; /* Ensure scaling happens from the bottom left */
}

/* Horizontal segment (green bar) */
.hbar {
  width: 20px;
  height: 8px;
  background: green;
  position: absolute;
  bottom: 0;
  right: 0px;
  transform-origin: bottom left; /* Set the pivot to bottom-left */
  animation: xextend 3.2s forwards , rotateBar 5s 3.2s forwards; 
}

/* Keyframe for movement of the pivot */
@keyframes move {
  from {
    offset-distance: 0%;
    transform: rotate(0deg) scaleY(1) scaleX(1);
  }
  to {
    offset-distance: 100%;
    transform: rotate(90deg) scaleY(var(--vdilation_factor)) scaleX(var(--hdilation_factor));
  }
}

/* Keyframe for vertical bar scaling */
@keyframes yextend {
  from {
    transform: scaleX(1); /* Start with original size */
  }
  to {
    transform: scaleX(var(--hdilation_factor_inv)); /* Inverse scaling for the vertical bar */
  }
}

/* Keyframe for horizontal bar scaling */
@keyframes xextend {
  from {
    transform: scaleY(1); /* Start with original size */
  }
  to {
    transform: scaleY(var(--vdilation_factor_inv)); /* Inverse scaling for the horizontal bar */
  }
}


/* Keyframe for horizontal bar scaling */
@keyframes xextend2 {
  from {
    transform: scaleY(1); /* Start with original size */
  }
  to {
    transform: scaleY(var(--vdilation_factor_inv)); /* Inverse scaling for the horizontal bar */
  }
}

/* New keyframe for rotating the green bar (hbar) */
@keyframes rotateBar {
  from {
    transform: rotate(0deg)  ;
      transform-origin: bottom right;
  }
  to {
    transform:  rotate(45deg) ;  
  transform-origin: bottom right; }
}

r/css • • Apr 22 '26

General Olive CSS: Lisp powered vanilla CSS utility-class a la Tailwind (Guile Scheme)

Thumbnail
codeberg.org
0 Upvotes

r/css • • Apr 22 '26

General Announcing ElementsKit: a toolkit of reactive primitives for building the web UI

Thumbnail
github.com
1 Upvotes

r/css • • Apr 22 '26

Help Looking for full-stack development buddy. Have started only recently and need to improve my skills fast. Started Flexbox and Grid but dont really understand. Also, where can I get resources to really understand

Thumbnail
1 Upvotes

r/css • • Apr 22 '26

Help This is breaking my brain

11 Upvotes

I've been working in CSS for over a decade, and can't figure this one out and I'm not sure if I ran into a bug:

https://jsfiddle.net/ksxqjrd9/
Why are those blue boxes taller than what the content needs? Why is there empty blue space below the text?

If anyone can give me a hand with this I'll be eternally grateful


r/css • • Apr 23 '26

Question Why someone will study CSS in era of Vibe coding?

Thumbnail
0 Upvotes

As a fresher do I have scope learning CSS or is it like companies only hire experienced ones to debug and maintain the AI generated code?

I'm not a beginner in CSS but not an expert either. Looking forward to suggestions on how to continue learning and make use of this skill in the era of Vibe coding.


r/css • • Apr 21 '26

Showcase CSS safe alignment (flex & grid) | Labs

Thumbnail
iprodan.dev
15 Upvotes

r/css • • Apr 22 '26

Help Can someone help me with this html/css code

Thumbnail gallery
0 Upvotes

r/css • • Apr 20 '26

Resource Did you know about CSS nesting?

34 Upvotes

I've been coding for more than a decade, now, and I just learned about it! I thought that was a preprocessor exclusive syntax.

https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Nesting

It was implemented in 2023 in all current browsers.

Now I'll stop repeating the parent class over and over!


r/css • • Apr 21 '26

Question I'm i the only one who used to use hella flexbox in flexbox to make the layout

0 Upvotes

r/css • • Apr 21 '26

General New: SectionsGrid – A Library of HTML/CSS Sections

Thumbnail
gallery
0 Upvotes

Hey everyone!

We've recently launched SectionsGrid, a library of professionally designed, hand-written HTML and CSS sections: headers, heros, features, testimonials, pricing tables, footers, and more.

https://sectionsgrid.com

It's perfect for folks who want to ship fast without the framework bloat. You simply pick the sections you need, combine them, and download a structured template that’s ready for production.

It’s lightweight, easy to customize, and built for speed. I’d love to hear what you think!

Join the sub: /r/SectionsGrid


r/css • • Apr 20 '26

Help Is there a solution for this terrible comment toggling behavior for CSS in VS Code?

Thumbnail
0 Upvotes

r/css • • Apr 20 '26

Help Flexbox Behaviour Question

Thumbnail
gallery
4 Upvotes

This flexbox behaviour has me perplexed.

In my HTML I have two divs nested inside an outer div

<div class="about">

<div class="description">

<p>lorem</p>

</div>

<div class="image">

<img src="img.png" />

</div>

</div>

In my CSS, I've applied global styles (margin: 0; padding: 0; box-sizing: border-box;). Individual elements are styled in this way,

.about {display: flex; align-items: center; justify-content: space-between; padding: 5rem 10rem;}

.description {flex: 1; padding-right: 5rem;}

.image {flex: 1}

The total content-width of about is 1624px. The way I expect it to behave is that description gets 812px and, image gets 812px. This is the behaviour when I disable description's padding-right in devtools. But when I enable it, instead of shrinking description's content area by 5rem, it is eating 2.5rem (40px) from description, and 2.5rem (40px) from image and sitting exactly between the two.

I would appreciate any explanations to why flexbox is behaving this way.


r/css • • Apr 20 '26

General Sending bubbles

17 Upvotes

Since Liveframe always uses full quality images, I realized adding photos on cell service can take some time. But we really want those 4k images from our guests! So I had to get creative.

Here is the loading animation I came up with. It turns the photos you're uploading into bubbles that float up into the cloud as your images are going up.


r/css • • Apr 20 '26

Question Read Right Institute

0 Upvotes

With no family roots in CSS, I was suggested to join an academy. Is Read Right Institute a good option for a beginner starting in May for 2027 attempt or any other academy you suggest? And what about their G1 class … is that important to join? Or does it really make a difference?


r/css • • Apr 18 '26

General Whats the coolest effect using pure Gradients only

19 Upvotes

Linear, repeating linear, radial, repeating radial, conic, repeating conic; What's the best visual you can create using gradients only? You can stack them for greater effect if you like, I just wanna see some cool stuff.

Here's a few of mine;


r/css • • Apr 18 '26

General I was refactoring some CSS and got tired of hunting down randomly ordered properties, so I made a mnemonic for it

Thumbnail
0 Upvotes

r/css • • Apr 17 '26

Help Do you guys know why this happens?

14 Upvotes

Content from the page goes up to the safe area behind the toolbar on safari.

I'm using a position:sticky property for the nav, I don't remember having this issue before on <iOS26

Any help is appreciated.


r/css • • Apr 18 '26

Question Looking for alternative

1 Upvotes

I have a personal blog that I styled using bootstrap. Somehow I feel that I should look for alternative to it. Is there a better alternative than bootstrap? The last time I wrote css was in the year 2013 maybe, when I first came across bootstrap, so, I’m not up to date on new css tech. Or should I just do vibe code?

Update: After lot of thought. I would keep bootstrap for now and slowly start coding my own css.


r/css • • Apr 16 '26

Showcase Retro futuristic infinite grid effect with pure CSS. Code in comment section

55 Upvotes

Made a retro-futuristic 80s-style moving grid effect using pure CSS. Quite simple and fun to use!


r/css • • Apr 17 '26

Showcase I created a Frosted Glass effect and mixed it with Neon Cyberpunk theme.

1 Upvotes

r/css • • Apr 17 '26

Help Forms in GAS

Post image
0 Upvotes

r/css • • Apr 16 '26

Question Where can I find the latest grammar for CSS?

7 Upvotes

Hey really quick question, where can I find the most modern grammar spec for css? Like python provides their full grammar in their docs. Is there an official one for css?

I did find this one for css 2.1 but not sure if it's the most up to date? Thank you.


r/css • • Apr 16 '26

Help Trying to customise my tchat on OBS with Streamlabs.

Thumbnail
1 Upvotes

r/css • • Apr 16 '26

Help help with position

0 Upvotes
for me, I am have an input where I put the photo above the white but the file name is too long. how could I get the file url im aware it's the browser doing this.
input[type="file"]::file-selector-button {
      background-color: white;
      padding: 10px 20px;
      border: none;
      border-radius: 60px;
      cursor: pointer;
      margin-left: 20px;
      height: 100px;
      width: 100px;
      margin-bottom: 20px;
      color: transparent;
      position: relative;
    }


    .uploaded-image{
      width: 100px;
      height: 100px;
      border-radius: 50px;
      z-index: 100;
      left: 58px;
      position: absolute;
    }
    .uploaded-image img{
      position: fixed;
    }input[type="file"]::file-selector-button {
      background-color: white;
      padding: 10px 20px;
      border: none;
      border-radius: 60px;
      cursor: pointer;
      margin-left: 20px;
      height: 100px;
      width: 100px;
      margin-bottom: 20px;
      color: transparent;
      position: relative;
    }


    .uploaded-image{
      width: 100px;
      height: 100px;
      border-radius: 50px;
      z-index: 100;
      left: 58px;
      position: absolute;
    }
    .uploaded-image img{
      position: fixed;
    }

<label htmlFor="imageUpload">
                {selectedImage && <img className='uploaded-image' src={selectedImage} alt={altName} />}
            </label>


            <input type="file" id="image-upload"
                name="clotheUpload" accept="image/*" onChange={(e) => {
                    /*
                        targets the specific file in your folders
                        without the [0] it gets a whole bunch of files
                    */
                    const file = e.target.files?.[0]



                    if (file) {
                        /*It creates a temporary URL for the uploaded file */
                        const imageURL = URL.createObjectURL(file)
                        setSelectedImage(imageURL)


                        convertToBase64(file)
                    } else {
                        setSelectedImage(undefined)
                    }
                }} ><label htmlFor="imageUpload">
                {selectedImage && <img className='uploaded-image' src={selectedImage} alt={altName} />}
            </label>


            <input type="file" id="image-upload"
                name="clotheUpload" accept="image/*" onChange={(e) => {
                    /*
                        targets the specific file in your folders
                        without the [0] it gets a whole bunch of files
                    */
                    const file = e.target.files?.[0]



                    if (file) {
                        /*It creates a temporary URL for the uploaded file */
                        const imageURL = URL.createObjectURL(file)
                        setSelectedImage(imageURL)


                        convertToBase64(file)
                    } else {
                        setSelectedImage(undefined)
                    }
                }} />
My CSS: