|
| 1 | +<!DOCTYPE html> |
| 2 | + |
| 3 | +<!-- |
| 4 | +Copyright 2017 Google Inc. |
| 5 | +
|
| 6 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +you may not use this file except in compliance with the License. |
| 8 | +You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | +Unless required by applicable law or agreed to in writing, software |
| 13 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +See the License for the specific language governing permissions and |
| 16 | +limitations under the License. |
| 17 | +--> |
| 18 | + |
| 19 | +<html lang="en"> |
| 20 | +<head> |
| 21 | + |
| 22 | +<script> |
| 23 | +// philipwalton.com/articles/the-google-analytics-setup-i-use-on-every-site-i-build |
| 24 | +window.ga = window.ga || function() { |
| 25 | + (ga.q = ga.q || []).push(arguments); |
| 26 | +}; |
| 27 | +ga('create', 'UA-33848682-1', 'auto'); |
| 28 | +ga('set', 'transport', 'beacon'); |
| 29 | +ga('send', 'pageview'); |
| 30 | +</script> |
| 31 | +<script async src="https://www.google-analytics.com/analytics.js"></script> |
| 32 | + |
| 33 | +<meta charset="utf-8"> |
| 34 | +<meta name="description" content="Simplest possible examples of HTML, CSS and JavaScript."> |
| 35 | +<meta name="author" content="//samdutton.com"> |
| 36 | +<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 37 | +<meta itemprop="name" content="simpl.info: simplest possible examples of HTML, CSS and JavaScript"> |
| 38 | +<meta itemprop="image" content="/images/icons/icon192.png"> |
| 39 | +<meta id="theme-color" name="theme-color" content="#fff"> |
| 40 | + |
| 41 | +<link rel="icon" href="/images/icons/icon192.png"> |
| 42 | + |
| 43 | +<base target="_blank"> |
| 44 | + |
| 45 | + |
| 46 | +<title>image-set()</title> |
| 47 | + |
| 48 | +<link rel="stylesheet" href="../css/main.css"> |
| 49 | + |
| 50 | +<style> |
| 51 | +div#background{ |
| 52 | + background-image: -webkit-image-set(url(small.jpg) 1x, url(large.jpg) 2x); |
| 53 | + background-size: cover; |
| 54 | + height: calc((100vw - 32px - 3em) * .5); |
| 55 | + margin: 0 0 20px 0; |
| 56 | + max-width: 40em; |
| 57 | + width: calc(100vw - 32px - 3em); |
| 58 | +} |
| 59 | +</style> |
| 60 | + |
| 61 | +</head> |
| 62 | + |
| 63 | +<body> |
| 64 | + |
| 65 | + <div id="container"> |
| 66 | + |
| 67 | + <h1><a href="../index.html" title="simpl.info home page">simpl.info</a> CSS background image-set()</h1> |
| 68 | + |
| 69 | + <div id="background" aria-label="Lias and Little Puss: two ten week old grey tabby kittens"></div> |
| 70 | + |
| 71 | + <p>In your browser developer tools, change the emulated device pixel ratio and reload the page.</p> |
| 72 | + |
| 73 | + <p>A browser that supports <code>CSS image-set()</code> will choose <a href="small.jpg" title="500px wide image file">small.jpg</a> or <a href="large.jpg" title="1500px wide image file">large.jpg</a>, depending on the device pixel ratio.</p> |
| 74 | + |
| 75 | + <p> |
| 76 | + Device pixel ratio: <span id="devicePixelRatio"></span><br> |
| 77 | + Viewport width: <span id="viewportWidth"></span>px<br> |
| 78 | + Available screen width: <span id="availableWidth"></span>px<br> |
| 79 | + </p> |
| 80 | + |
| 81 | + <a href="https://github.com/samdutton/simpl/blob/gh-pages/imageeset" title="View source for this page on GitHub" id="viewSource">View source on GitHub</a> |
| 82 | + |
| 83 | + </div> |
| 84 | + |
| 85 | + <script src="js/main.js"></script> |
| 86 | + |
| 87 | +</body> |
| 88 | +</html> |
0 commit comments