Tuesday, June 28, 2022
  • Home
  • Event
  • Technology
  • Program
  • Education
No Result
View All Result
I-Capitals
No Result
View All Result
Home Program

Maybe there kinda is background-opacity?

admin by admin
December 16, 2021
in Program
0
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

I was reading Jake’s “Cross-fading any two DOM elements is currently impossible” which is a wonderfully nerdy deep dive into how there is no real way to literally cross-fade elements. Yeah, you can animate both of their opacities, but even that isn’t quite the same. Turns out there is a Chrome/WebKit-only CSS function call called -webkit-cross-fade() that does the trick. MDN says it’s specced, but the implemented version differs, so it’s a bit of a mess… but it does exist:

Related Posts

My Dumbest CSS Mistakes | CSS-Tricks

Great Web Development Books You Can Read Free | CSS-Tricks

Top 10 Computer Science Universities in USA 2022

Single Element Loaders: The Bars | CSS-Tricks

.el {
  background: -webkit-cross-fade(url(img1.svg), url(img2.svg), 50%);
}

I didn’t even know that was a thing.

The first thing I thought of was: if one of the images was just a blank transparent image, wouldn’t that apply partial transparency to the other one? And thus it’s kind of a proxy for background-opacity (which doesn’t exist but feels like it should).

I gave it a test to see if it would work:

It seems to work! This is the meat of it:

.el {
  background-image: -webkit-cross-fade(
    url(image.jpg),
    url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7),
    50%
  );

That’s a 1px transparent GIF Base64 encoded.

It doesn’t work in Firefox but it does in everything else. Plus, you can test for support right in CSS and do something different if this isn’t just an enhancement.

@supports (background: -webkit-cross-fade(url(), url(), 50%)) {

  /* Only apply the idea if supported, do the Firefox fallback outside of this */

}

That’s baked into the demo above.

Next Post

Some Thoughts On Knowledge And Knowledge Limits

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular Posts

Education

Teachers Can Score Major Deals!

by admin
June 28, 2022
0

Tips for Getting the Best Amazon Prime Day Deals in 2022 Need tips on how to navigate Prime Day and...

Read more

Teachers Can Score Major Deals!

Shares of companies that went public via SPAC fall more than 50% – GeekWire

Classroom Rules Posters Every Teacher Needs

My Dumbest CSS Mistakes | CSS-Tricks

Free Word Cloud Generators for Teachers and Students in the Classroom

Your Guide to Teacher Certification Exams in Every State

Load More

Popular Posts

2021 Event Tech Investments and Acquisitions Review

by admin
January 10, 2022
0

Microsoft detected ‘destructive cyberattacks’ against Ukraine hours before Russian invasion

by admin
February 28, 2022
0

2022 Award-Winning Kids Books–Perfect for the Classroom Library

by admin
February 2, 2022
0

Copyright © 2021 - i-Capitals.com DESIGNED AND DEVELOPED BY TEAM WORDPRESS BLOGX

No Result
View All Result
  • Home
    • Home 1
    • Home 2
    • Home 3
  • Event
  • Technology
  • Program
  • Education

Copyright © 2021 - I-capitals.com - DESIGNED AND DEVELOPED BY TEAM WORDPRESS BLOGX