Filtered background with fallback for legibility

Developer
Size
2,838 Kb
Views
12,144

How do I make an filtered background with fallback for legibility?

See the explaining blog post: codepen.io/tigt/post/blurred-background-image-with-fallback. What is a filtered background with fallback for legibility? How do you make a filtered background with fallback for legibility? This script and codes were developed by Taylor Hunt on 29 September 2022, Thursday.

Filtered background with fallback for legibility Previews

Filtered background with fallback for legibility - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Filtered background with fallback for legibility</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <header> <h1> You won’t believe these 17 “articles” our editors thought were good enough to publish <small>p.s. let us track you ok bye</small> </h1> <p>Want to get into journalism? Better learn how to search for “relatable meme GIFs,” as you'll see in this hard-hitting exposé…</p>
</header> <script src="js/index.js"></script>
</body>
</html>

Filtered background with fallback for legibility - Script Codes CSS Codes

/* Stretch out the two pseudo-elements across the entirety of their parent element */
header::before,
header::after { content: ""; display: block; position: absolute; width: 100%; height: 100%; left: 0; top: 0;
}
header::before { background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/183091/Black_and_white_branch.jpg"); /* Specified separately for older versions of Android/Safari that choke on background-size when used inside the `background` shorthand property. */ background-size: cover; /* Move underneath the backdrop's content. */ z-index: -2; -webkit-filter: blur(5px) brightness(0.75); filter: blur(5px) brightness(0.75); /* Make it a little bigger to avoid the white bleeding from the edges that the `blur()` filter produces. */ -webkit-transform: scale(1.07); transform: scale(1.07);
}
header::after { z-index: -1; background: rgba(0,0,0, 0.5); /* If filters are unsupported, then this fallback color wash remains to make sure the text stays legible. Test this pen in IE! */ -webkit-filter: opacity(0); filter: opacity(0);
}
/* * * Now for some styling that's not related to this trick. * * */
html,
body,
header { height: 100%; margin: 0;
}
body { color: #fff; display: table; /* This is a trick to make viewport-unit-sized text zoomable, see https://codepen.io/AmeliaBR/details/RNXeyd/ */ font-size: calc(0.5em + 2vmin); overflow: hidden;
}
header { display: table-cell; padding: 0.5em; position: relative; vertical-align: middle;
}
h1 { text-align: center; text-transform: uppercase;
}
small { display: block; font-size: 70%; margin: 0.75em; opacity: 0.8;
}
p { max-width: 25em; margin: 1em auto;
}

Filtered background with fallback for legibility - Script Codes JS Codes

/* Image credit: https://commons.wikimedia.org/wiki/File:Black_and_white_branch.jpg */
/* Explanation of what's going on in this pen: https://codepen.io/tigt/post/blurred-background-image-with-fallback
*/
Filtered background with fallback for legibility - Script Codes
Filtered background with fallback for legibility - Script Codes
Home Page Home
Developer Taylor Hunt
Username tigt
Uploaded September 29, 2022
Rating 3
Size 2,838 Kb
Views 12,144
Do you need developer help for Filtered background with fallback for legibility?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Taylor Hunt (tigt) Script Codes
Create amazing marketing copy with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!