Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

#tinyCSStip You may have seen some of my demos using this on CodePen.IO already. Pure CSS halftone effect in 3 declarations: ✨ background layering a pattern and a map ✨ blend mode multiplication of the two layers ✨ contrast bump up to push all greys to either black or white

27,203 görüntüleme • 2 yıl önce •via X (Twitter)

10 Yorum

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

I first came up with the idea and gave a talk on it almost half a decade ago. And then I refined the topic a bit for another talk which used these slides you may have seen me share before.

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

Pattern part may be anything small & repeating. We may also use thin blurry stripes - linear-gradient, rays - repeating-conic-gradient, rings - repeating-radial-gradient Map part may also be another type of gradient or even a .jpg

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

A `linear-gradient()` pattern coupled with a `linear-gradient()` map is what's behind this retro wave demo And animating the map's `background-position` is how we get this progressive close/ open blinds effect

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

The .jpg image map case is... special. Most of my demos use extra pseudos/ elements and `mix-blend-mode` for compatibility reasons. But Safari, only browser to support `filter()` (*not* `filter`!) allows for the no extra pseudo/ element #halftone solution

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

Animating a custom property* that the gradients used for the effect depend on can also produce cool effects, like in - also an entry for this week's #CodePenChallenge😎 And a solution to *not yet in Firefox stable, only in Nightly

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

A couple more such halftone patterns, both of which have a video of me coding them from scratch. ✨ ✨ #CSS

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

And here are two more demos showcasing animated halftone patterns, while the elements they're on either fill the full viewport or are positioned in 3D. ✨ ✨ #CSS

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

Finally, some pure #CSS, single element halftone patterned cards: ✨ ✨

Ana Tudor 🐯🖤🌻 profil fotoğrafı
Ana Tudor 🐯🖤🌻2 yıl önce

3 more such animated pure #CSS, single element animated halftone patterns on @CodePen: ✨ ✨ ✨

🎗️ daniel haim profil fotoğrafı
🎗️ daniel haim2 yıl önce

@CodePen 🤯

Benzer Videolar

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 görüntüleme • 2 yıl önce

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 görüntüleme • 2 yıl önce

CSS Trick! 🤙 You can create gradient borders on translucent elements using mask-clip and mask-composite with a pseudo-element 🔥 .gradient-border::after { mask-clip: padding-box, border-box; mask-composite: intersect; mask: linear-gradient(transparent, transparent), linear-gradient(white, white); } It's the same "Transparent border trick" from before. But, now you apply it to a pseudo-element 😎 The trick is to create a pseudo-element with a gradient background and then mask it so we only see the part we want, the border ✨ mask-clip defines the area affected by a mask. Similar to how you can define background-size. Using padding-box and border-box constrains the two masks. mask-composite is the magic part ✨ It defines a compositing operation for stacked mask layers. Using intersect means that the parts that overlap get replaced. And this seems to work in all browsers 🙌 As for the rest of the styles... – Make sure you set pointer-events: none on the pseudo-element – Make sure it fills the parent element. You can use position: absolute and inset: 0 – Make sure the background fills the space including the border-width. You can use calc to achieve that: --bg-size: calc(100% + (2px * var(--border))); background: var(--gradient) center center / var(--bg-size) var(--bg-size); That's it! 🚀 Gradient borders on translucent elements. You can set all the backdrop-filter: blur() you like! 😅 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

269,739 görüntüleme • 2 yıl önce

Dark mode prevents myopia (nearsightedness). Dr. Alexander Wunsch, German physician studying the effects of light on health for 30+ years: "Whenever the opportunity arises to read text white on black, we should do so." Here's the mechanism: Your retina has two cell systems — ON cells and OFF cells. Black letters on white background activate the OFF cell system. Chronic activation of the OFF cell system promotes the development of myopia. Dark mode — white text on black background — activates the ON cell system instead. This is the preventive mechanism. There is also a significant difference in total light load: > Standard display (white background, black text): 95% of screen light is emitted to display the page. Only 5% is the actual text. > Dark mode (black background, white text): only 5% of total light is needed to convey the same information. Less light from the screen. The correct cell system is activated. Lower myopia risk. The first computer screens were dark mode by default — black background, green or amber text. That was optimal. The shift to white backgrounds was aesthetic, not biological. University of Tübingen, 2018 — researchers developed a mathematical model analyzing image content for myopia risk potential. Their finding? Natural outdoor scenes have a neutral effect on the eye. Conventional text on white background promotes myopia development. Dark mode presentation does not. They then tested this in subjects. Black letters on white background produced measurable changes in the eye that promote myopia. In Europe, half of all students are already nearsighted. Myopia is the most common visual impairment among young people. The more a child reads — the higher the risk. The mechanisms are not yet fully understood in all details. But the consequences are clear. Wunsch: "Dark mode is recommended wherever it does not impair the workflow during screen work." "In the evening and at night, this should be the mandatory setting in order to keep the disruption of the internal clock and the possible damage to the retina as low as possible." Wunsch's advice to parents: "If children discover the joy of reading and develop into bookworms, it is certainly a good investment to provide them with an e-book reader that enables text display on a dark background." The original screen setting was black background. We changed it for aesthetics. The biology didn't change with it.

no.mind

56,281 görüntüleme • 2 ay önce