Skip navigation
CSS Trick 🖼️ You could take the resize trick from last week and use it to create one of those…
0:00 / 0:30

CSS Trick 🖼️ You could take the resize trick from last week and use it to create one of those…

jhey ʕ•ᴥ•ʔ

@jh3yy149K followers

Visit on X
424 likesDownloadOriginal post

111,499 views

CSS Trick 🖼️ You could take the resize trick from last week and use it to create one of those sliding image components 👀 CSS only, JavaScript to enhance later 🤓 Put an image in each panel and make them position: absolute. They can use a container query unit for their size 🫶 img { position: absolute; width: 100cqi; // Make them the container width 🤙 } .panel:last-of-type img { right: 0; } The rest of the trick from last week was using display:grid with grid-template-columns. Then we have a resizable element inside the first column 😎 .panels{ display: grid; grid-template-columns: auto 1fr; 👈 } .resizer{ max-width: 100cqi; overflow: hidden; resize: horizontal; 👈 } Where does JavaScript come in? To progressively enhance the thing with keyboard controls ✨ Not 100% sure of the pattern for that though. Feels like it should be a button that you can toggle into resize mode and then use left/right to resize 🤔 Anyways, CodePen.IO link below! 👇

8 Comments

Comments from the original post on X (Twitter)

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    Here's that @CodePen link! 🚀 To be honest, it's jus' messin' with the concept from last week for an article 😁 The design could totally be improved for sure 💯 Would love your input on that! 📢

    16 likes

  • wés's profile picture

    @wesleycoder

    It just came up in my mind that a <progress /> should fit in there somehow to help with the js enhancement. But the more I think about it the more it seems too convoluted. Maybe someone can improve the idea or just tell me how wrong I am.

    1 like

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    Ha 😅 It's a tricky one for sure. Same goes for the Drag and Drop API which is where my thinking takes me. To make that API a11y friendly, you can use space to toggle into the drag mode and then use arrow keys if I recall. The same could be done here with a tabbable button that's visually hidden 🤔

    2 likes

  • JEM's profile picture

    @Jacksonmills

    Wowowowowow saving this for later

  • Christo's profile picture

    @chroxify

    sweet! 👏

  • Arpit Adlakha's profile picture

    @arpit20adlakha

    Amazing 🤩

  • Arghya Das's profile picture

    @itsarghyadas

    Should I try that in tailwindcss?🤔we will need custom CSS but I can try.

  • 高冷小姨's profile picture

    @barton68453

    @rayc2045 The Garden awaits... The fight is comin'. Let's make your Banner cooler @rayc2045 🎯 Simple type: @MokugyoAI Banner Azuki ID Prompt Ex: @MokugyoAI Banner Azuki 1234 Shanghai Let's connect together!!! IKUZO ⛩️