MQ-based Content-controlled Optional Image Loading
How do I make an mq-based content-controlled optional image loading?
This is a test. I want to see if we can reliably load images only within specific media queries using only HTML and CSS without causing issues in older browsers.. What is a mq-based content-controlled optional image loading? How do you make a mq-based content-controlled optional image loading? This script and codes were developed by Aaron Gustafson on 13 August 2022, Saturday.
MQ-based Content-controlled Optional Image Loading - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>MQ-based Content-controlled Optional Image Loading</title> <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> <h1>MQ-based Content-controlled Optional Image Loading</h1>
<p>This is a test. I want to see if we can reliably load images only within specific media queries using only HTML and CSS without causing issues in older browsers.</p>
<p>On modern browsers rendering with a screen width of 20em or above, an image should be displayed in the box below. On older browsers or browsers displaying below 20em, you should <strong>not</strong> see an image, a broken image icon, or (optionally) displayed <code>alt</code> text (typically displayed because the <code>src</code> is not available).</p>
<p>Drumroll…</p>
<div class="image-container">
<img sizes="(min-width: 40em) 80vw, (min-width: 20em) 100vw" srcset="http://scottjehl.github.io/picturefill/examples/images/medium.jpg 375w, http://scottjehl.github.io/picturefill/examples/images/medium.jpg 480w, http://scottjehl.github.io/picturefill/examples/images/large.jpg 768w" alt="This alt text could be optionally displayed.">
</div>
<small>Image and basic <code>img</code> syntax lifted from <a href="http://scottjehl.github.io/picturefill/">the Picturefill documentation</a></small> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
</body>
</html>
MQ-based Content-controlled Optional Image Loading - Script Codes CSS Codes
@charset "UTF-8";
/* Hide all images */
img { position: absolute; overflow: hidden; width: 0; height: 0;
}
/* Show traditional images */
img[src] { position: static; width: auto; height: auto;
}
/* Optional: In modern browsers, hide alt text for non-src’d images */
img[alt]:not([src]):before,
img[alt]:not([src]):after { position: absolute; overflow: hidden; width: 0; height: 0;
}
/* Images should only appear > 20em on modern browsers */
@media only screen and (min-width: 20em) { /* Bring images back universally */ img { position: static; width: auto; height: auto; } /* Debugging something in IE9+ */ img:not([src]) { position: absolute; overflow: hidden; width: 0; height: 0; } img[srcset]:not([src]) { position: static; width: auto; height: auto; }
}
/* Demo styles - irrelevant to the concept */
body { padding: 0 1em;
}
small { display: block; font-style: italic; margin: 1em 0;
}
.image-container { border: 1px solid; background: #ccc; padding: 1em;
}
Developer | Aaron Gustafson |
Username | aarongustafson |
Uploaded | August 13, 2022 |
Rating | 3 |
Size | 3,047 Kb |
Views | 38,456 |
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!
Name | Size |
Visualizing CSS Transforms | 3,155 Kb |
Zoom Layouts v2 | 2,098 Kb |
Validation rules jQuery plugin | 2,768 Kb |
FAQ JS-Enhanced Tab Order | 3,573 Kb |
Un-doing tables | 3,993 Kb |
Simple pull quote | 3,392 Kb |
Easy Obfuscated Field | 2,393 Kb |
Easy Couch Mode | 8,819 Kb |
Form Patterns | 5,922 Kb |
Pure CSS knockout arrow | 2,344 Kb |
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!
Name | Username | Size |
Animated Vertical CSS3 Menu Black | MaCeLMp4 | 2,750 Kb |
Hover Animation from UNIQLO | Insprd | 3,772 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
Angular Sandbox | Alexgurrola | 1,616 Kb |
A Pen by Brendan Skousen | Bskousen | 2,954 Kb |
Flat Star Wars | Kevinjannis | 37,947 Kb |
Cool audio | Bigliam | 1,868 Kb |
CSS- UI Element States Pseudo-Classes | Tesla809 | 2,206 Kb |
Addthis_button | Esambino | 1,691 Kb |
Donald Trump - The New Yorker | Agbales | 2,502 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!