Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Future CSS Tip! ๐Ÿš€ You can create auto-resizing text inputs with one line of CSS ๐Ÿ”ฅ textarea, input { field-sizing: content; } No more JavaScript to sync a textarea height to fit the content ๐Ÿซถ Perfect for chat, messaging, comments, etc. ๐Ÿ’ฌ The size of your input will grow...

319,234 Aufrufe โ€ข vor 2 Jahren โ€ขvia X (Twitter)

20 Kommentare

Profilbild von jhey โ–ฒ๐Ÿป๐ŸŽˆ
jhey โ–ฒ๐Ÿป๐ŸŽˆvor 2 Jahren

Here's that @CodePen link! ๐Ÿš€ Only available in Chrome Canary at the moment ๐Ÿฅฒ Fallback would be that your inputs don't resize unless you tap into it with some JavaScript โœจ

Profilbild von PDF GPT
PDF GPTvor 2 Jahren

Everyone is getting ahead with AI. You should be too. Summarize documents, craft emails, and generate custom content instantly with this powerful tool. It's like having ChatGPT tailored for your job. Try it for free.

Profilbild von Kartuzinski
Kartuzinskivor 2 Jahren

Nice. I also saw @wesbos tweeting about this. This is quite a big deal!

Profilbild von jhey โ–ฒ๐Ÿป๐ŸŽˆ
jhey โ–ฒ๐Ÿป๐ŸŽˆvor 2 Jahren

@wesbos Yeah, such a great addition! ๐Ÿซถ It went through a little renaming recently, was going to be slightly different a couple of months ago. Like the new name ๐Ÿ’ฏ

Profilbild von Anthony Riera
Anthony Rieravor 2 Jahren

No freaking way, I've been struggling so much with that ๐Ÿ˜‚ You saved us sir

Profilbild von App Beast
App Beastvor 2 Jahren

Really nice once it actually is available in many browsers.

Profilbild von jhey โ–ฒ๐Ÿป๐ŸŽˆ
jhey โ–ฒ๐Ÿป๐ŸŽˆvor 2 Jahren

Yeah, fortunately, we have "supports" so we can get things in place as a nice Easter egg for those using supported browsers. Kinda nice too as it makes you think a bit more about design as you implement things I've found โœจ

Profilbild von Floris
Florisvor 2 Jahren

What would be the fallback for non-supported browsers?

Profilbild von Vitor Markis
Vitor Markisvor 2 Jahren

ho do you add this smooth cursor effect on your vids? I'm so obsessed with it

Profilbild von Veer Singh
Veer Singhvor 2 Jahren

what software do you use to edit your tutorials like this ?

Profilbild von Helloyunho
Helloyunhovor 2 Jahren

@discord time to use the css instead of js lol

Profilbild von coirElephant
coirElephantvor 2 Jahren

I usually used javascript scrollheight method to achieve it.

Profilbild von Uday Mungalpara
Uday Mungalparavor 2 Jahren

Amazing ๐Ÿ‘๐Ÿ‘

Profilbild von marissa27r
marissa27rvor 2 Jahren

๐Ÿคฏโค๏ธ

Profilbild von MikeeBuilds โ›ฉ๏ธใ€ฐ๏ธ๐Ÿงฑ
MikeeBuilds โ›ฉ๏ธใ€ฐ๏ธ๐Ÿงฑvor 2 Jahren

Saw this on LinkedIn today. Good that this tip is spreading and making the rounds. Makes it much easier ๐Ÿ’ฏ๐Ÿ‘๐Ÿพ

Profilbild von Sourov Basu
Sourov Basuvor 2 Jahren

Cool tip

Profilbild von Mohan kumar
Mohan kumarvor 2 Jahren

Does this support every browser?

Profilbild von TForrest
TForrestvor 2 Jahren

How did you do the glow effect on the border? It was so clean ๐Ÿฅถ

Profilbild von Frank Stallone ๐Ÿง˜๐Ÿปโ€โ™‚๏ธ
Frank Stallone ๐Ÿง˜๐Ÿปโ€โ™‚๏ธvor 2 Jahren

What do you use to record these screens? Super slick with the zooming in and out effects. As always thatโ€™s for sharing and ask the help! ๐Ÿ‘๐Ÿป๐Ÿ™๐Ÿป๐Ÿ™Œ๐Ÿผ

Profilbild von Juan Cruz
Juan Cruzvor 2 Jahren

Awesome, thatโ€™s great!

ร„hnliche Videos

CSS Trick ๐Ÿค™ You can create these tab bar controls by using :has() to count the number of tabs โญ๏ธ .tabs:has(input:nth-of-type(3)){--count: 3;} .tabs:has(:checked:nth-of-type(3)){--active: 200%;} .tabs::after{ translate:var(--active) 0;} Let's break it down in this ! ๐Ÿ“ผ Couple of CSS :has() tricks here combined with custom properties ๐Ÿ˜Ž First things first, lay out the tabs using display: grid. This gives you a way to create equal-width tabs ๐Ÿ™ .tabs { display: grid; grid-auto-flow: column; } Then you use :has() to count the number of tabs and store that in a custom property ๐Ÿค“ .tabs:has(input:nth-of-type(3)) { --count: 3; } .tabs:has(input:nth-of-type(4)) { --count: 4; } Using the cascade, the last valid :has() gives you the number of tabs ๐Ÿซถ Using the tab count, you can size the tab indicator. For the tab indicator, use the tabs pseudoelement: .tabs::after { content: ""; position: absolute; height: 100%; width: calc(100% / var(--count)); } See how you can use --count to determine its size ๐Ÿ“ Next, use :has() to determine which tab is active or :checked with input [type=radio] .tabs:has(:checked:nth-of-type(2)) { --active: 1; } .tabs:has(:checked:nth-of-type(3)) { --active: 2; } You can use a zero-indexed translation here. If the second input is :checked, set --active: 1, then translate the pseudoelement on the tabs to that position ๐Ÿ‘‰ .tabs::after { translate: calc(var(--active, 0) * 100%) 0; } Or you could set active to the translation: .tabs:has(:checked:nth-of-type(2)) { --active: 100%; } Setting the custom property allows you to use the index elsewhere if you need it ๐Ÿค™ The final piece is using mix-blend-mode ๐Ÿ‘€ The tabs have a black background-color, the pseudoelement is white, and the label text is white. When you use mix-blend-mode: difference on the pseudoelement it will give this effect that the text transitions from white to black sliding across ๐Ÿ˜Ž .tabs::after { color: hsl(0 0% 100%); mix-blend-mode: difference; } You can totally mix up the colors here though and go with a different effect. The mechanics of how you can use CSS :has() is the main point here ๐Ÿ™ As always, any questions, suggestions, etc. let me know CodePen.IO link below! ๐Ÿ‘‡ (There's even a Tailwind CSS play for this one too ๐Ÿ‘€)

jhey ส•โ€ขแดฅโ€ขส”

70,730 Aufrufe โ€ข vor 2 Jahren

CSS Tip! ๐Ÿ’ช You can create these tab controls with CSS :has() + radio buttons โœจ .tabs:has(input:nth-of-type(3)) { --count: 3; } .tabs:has(:checked:nth-of-type(3)) { --active: 2; } .tabs::after { translate: calc(var(--active, 0) * 100%) 0; width: calc(100% / var(--count)); } Two CSS :has() tricks here combined with a rendering trick ๐Ÿค™ The tab control is a container using display: grid. You can use :has() to count the number of tabs in the container: .tabs:has(input:nth-of-type(3)) { --count: 3; } .tabs:has(input:nth-of-type(4)) { --count: 4; } Using the cascade, the last valid :has() gives you the number of tabs ๐Ÿซถ Once you know the number of tabs, you know how to size the indicator: .tabs::after { content: ""; position: absolute; height: 100%; width: calc(100% / var(--count)); } It's a pseudoelement that uses --count to determine its size ๐Ÿ“ The next :has() trick is determining which tab is active or :checked as it's an input [type=radio] .tabs:has(:checked:nth-of-type(2)) { --active: 1; } .tabs:has(:checked:nth-of-type(3)) { --active: 2; } You can use a zero-indexed translation here. If the second input is :checked, set --active: 1, then translate the pseudoelement on the tabs to that position ๐Ÿ‘‰ .tabs::after { translate: calc(var(--active, 0) * 100%) 0; } The last rendering trick is using mix-blend-mode ๐Ÿ‘€ The tabs have a black background-color, the pseudoelement is white, and the label text is white. When you use mix-blend-mode: difference on the pseudoelement it will give this effect that the text transitions from white to black sliding across ๐Ÿ˜Ž .tabs::after { color: hsl(0 0% 100%); mix-blend-mode: difference; } You can totally mix up the colors here though and go with a different effect. The mechanics of how you can use CSS :has() is the main point here ๐Ÿ™ As always, any questions, suggestions, etc. let me know CodePen.IO link below! ๐Ÿ‘‡ (There's even a Tailwind CSS play for this one too ๐Ÿ‘€)

jhey ส•โ€ขแดฅโ€ขส”

437,487 Aufrufe โ€ข vor 2 Jahren

CSS Tip! โœจ You can create these parallax effects and image cross-fades with scroll-driven animations ๐Ÿค™ img { animation: fade; animation-timeline: view(); mix-blend-mode: plus-lighter } img:last-of-type { animation-direction: reverse; } @โ€‹keyframes fade { to { opacity: 0; }} This one's fun! ๐Ÿ˜ The trick with the cross-fading image is to make use of one animation that runs at the same time on two images inside a container. You use the same animation, animation-timeline, and animation-range. But, you use animation-direction: reverse on one of the images so they go in the opposite direction ๐Ÿซถ The use of mix-blend-mode: plus-lighter; produces a better cross-fade result ๐Ÿ’ฏ A viewTimeline (view()) works because you know that both images are the same height. The range you can use is img { animation-timeline: view(); animation-range: cover 45% cover 55%; } That means when the image has covered 45% of the scrollport (In this case, the window), start the animation. And finish when it has covered 55% ๐ŸŽฌ How about the slight parallax? This is a trick with calc(). You know the top of the small image and the big image line up. And you can do this by absolutely placing the caption outside of the small image. The trick is to translate the small image by a distance so it lines up with the bottom of the big image. You can do that like this :root { --catch-up: calc( var(--big-height) - var(--small-height) ); } @โ€‹keyframes move { to { translate: 0 var(--catch-up); }} Then drive that animation with a scroll-driven animation using the container of both images as the driver ๐Ÿค™ /* section contains both images */ section { view-timeline: --container; } .img-fader { animation: catch-up both linear; animation-timeline: --container; animation-range: 50vh calc(100vh + (var(--big-height) * 0.25)); } That's it! Scroll-driven image cross-fading and parallax effects without any JavaScript. This demo will work in all browsers as there is some JavaScript in place where the API isn't supported ๐Ÿค™ To do that, it uses GSAP ScrollTrigger ๐Ÿ† As always, any questions, requests, etc. hit me up! ๐Ÿค™ CodePen.IO link below ๐Ÿ‘‡

jhey ส•โ€ขแดฅโ€ขส”

242,074 Aufrufe โ€ข vor 2 Jahren

CSS Tip! ๐Ÿคฏ You can create a CSS-only version of this balance slider using a scroll animation on the underlying input[type=range] ๐Ÿš€ ::-webkit-slider-thumb { view-timeline: --thumb inline; } Scroll animation driven by the slider thumb animates a number between the "min" and "max" of the range ๐Ÿ˜… @โ€‹property --value { inherits: true; initial-value: 0; syntax: ' '; } @โ€‹keyframes sync { to { --value: 100; }} Tie that up to the contain animation-range โšก๏ธ .control { animation: sync both linear reverse; animation-timeline: --thumb; animation-range: contain; } Hoist the view timeline so all the parts of the control can use it! .control { timeline-scope: --thumb; } Use that value in a counter which is used for the labels. Create a low and a high for each side ๐Ÿ˜‡ .control__label { counter-reset: low var(--value) high calc(100 - var(--value)); } .control__label::before { content: "COFFEE " counter(low) "%"; } .control__label::after { content: counter(high) "% MILK"; } That's the magic of updating the label values โœจ For the big track, it's a fake track. You can make use of the same --value property and do some calc() to work out the width of each part. .control__track::before { width: calc(var(--value) * 1% - 0.5rem); background: var(--coffee); border-radius: 4px; transition: width 0.1s; } The width leaves a little gap for the indicator piece ๐Ÿค™ The color calculation for --coffee isn't too wild but again you can use the same --value .control__track { --coffee: hsl(24 74% calc( 24% + (30% * ((100 - var(--value, 0)) / 100)) / 1 ) / 0.4); } Now for the last piece. Making the track change height. You could set up another custom property and animate its value using the --thumb timeline too ๐Ÿ”ฅ @โ€‹property --shift { initial-value: 0; inherits: true; syntax: ' '; } @โ€‹keyframes shift { 0%, 31%, 61%, 100% { --shift: 0; } 32%, 60% { --shift: 1; } } Then use that --shift to update the translation of the label and height of the track ๐Ÿค“ .label { transform: translateY(calc(var(--shift) * 50%)); transition: transform var(--speed) var(--timing); } Cool part here is that you can use the control to work out the @โ€‹keyframes percentages ๐Ÿ˜… Oh. And the timing for that little bounce? Use the linear() function ๐Ÿ˜Ž :root { --timing: linear( 0, 0.5007 7.21%, 0.7803 12.29%, 0.8883 14.93%, 0.9724 17.63%, 1.0343 20.44%, 1.0754 23.44%, 1.0898 25.22%, 1.0984 27.11%, 1.1014 29.15%, 1.0989 31.4%, 1.0854 35.23%, 1.0196 48.86%, 1.0043 54.06%, 0.9956 59.6%, 0.9925 68.11%, 1 ); } Should probably do a video on this one. Lots of little custom property tricks for sure! ๐Ÿ’ฏ It's not too far off the range slider with the tooltip that came up previously As always, any questions, let me know! Also, this one only works in Chrome currently โœ…๐Ÿฅฒ This one's a bit rocket science ha ๐Ÿš€ CodePen.IO link below! ๐Ÿ‘‡

jhey ส•โ€ขแดฅโ€ขส”

377,586 Aufrufe โ€ข vor 2 Jahren

CSS in 2024 ๐Ÿคฏ You can create a range slider with updating value tooltip and color changing track without using any JavaScript ๐Ÿคฏ ::-webkit-slider-thumb{ view-timeline: --thumb inline; } Scroll animation on the slider thumb that animates a number between the "min" and "max" of the range ๐Ÿ˜… @โ€‹property --value { syntax: ' '; } @โ€‹keyframes sync { to { --value: 100; }} Tie that up to the contain animation-range โšก๏ธ .control { animation: sync both linear reverse; animation-timeline: --thumb; animation-range: contain; } Hoist the view timeline so the tooltip can use the value too! :root { timeline-scope: --thumb; } Then use it in the counter which goes in the tooltip ๐Ÿ˜‡ .tooltip { counter-reset: val var(--value); } .tooltip::after { content: counter(val); } Then the accent color is based on the value too ๐ŸŽจ [type=range] { accent-color: hsl(var(--value) 90% 65%); } The magic from the quoted post is using anchor positioning on the range thumb to position that tooltip ๐Ÿ‘ Never thought of that when working on the spec for this API. This API lets you tether elements to other elements. Using the pseudo is a clever move! ::-webkit-slider-thumb { anchor-name: --thumb; } .tooltip { position: absolute; anchor-default: --thumb; left: anchor(50%); bottom: calc(anchor(top) + 25%); } The last piece is the little bounce transition... OK. I used a line or two of JavaScript for that ๐Ÿ™๐Ÿ˜ฌ const updateDelta = ({ movementX }) => { documentโ€‹.documentElementโ€‹.style.setProperty('--delta-x', movementX) } document.body.addEventListener('pointermove', updateDelta) But only so you can pass the movement delta to CSS and then reset the position with linear() to get that bouncy transition ๐Ÿ˜Ž .hint { rotate: calc(clamp(-60, var(--delta-x) * -1, 60) * 1deg); transition: rotate 1s linear( 0, 0.2178 2.1%, 1.1144 8.49%, ... ); } Should probably do a video on this one. Lots of little tricks to break down with it for sure! ๐Ÿ’ฏ As always, any questions, let me know! Also, this one only works in Chrome Canary with the Experimental Web Platform Features flag enabled โœ… This one almost feels like rocket science ha ๐Ÿš€ CodePen.IO link below! ๐Ÿ‘‡

jhey ส•โ€ขแดฅโ€ขส”

251,867 Aufrufe โ€ข vor 2 Jahren