object-position-png-002c.html (2354B)
1 <!DOCTYPE html> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <html class="reftest-wait"> 7 <head> 8 <meta charset="utf-8"> 9 <title>CSS Test: various 'object-position' values on a fixed-size canvas element, with a PNG image and 'object-fit:contain'.</title> 10 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"> 11 <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing"> 12 <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit"> 13 <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position"> 14 <link rel="match" href="object-position-png-002-ref.html"> 15 <style type="text/css"> 16 canvas { 17 background: lightgray; 18 margin-right: 2px; 19 object-fit: contain; 20 image-rendering: pixelated; /* for UAs that don't support crisp-edges */ 21 image-rendering: crisp-edges; 22 float: left; 23 width: 20px; 24 height: 20px; 25 } 26 27 .op_x-7 { object-position: -7% 50% } 28 .op_x13 { object-position: 13% 50% } 29 .op_x23 { object-position: 23% 50% } 30 .op_x50 { object-position: 50% 50% } 31 .op_x75 { object-position: 75% 50% } 32 .op_x88 { object-position: 88% 50% } 33 .op_x111 { object-position: 111% 50% } 34 35 </style> 36 <script> 37 function drawImageToCanvases(imageURI) { 38 var image = new Image(); 39 image.onload = function() { 40 var canvasElems = document.getElementsByTagName("canvas"); 41 for (var i = 0; i < canvasElems.length; i++) { 42 var ctx = canvasElems[i].getContext("2d"); 43 ctx.drawImage(image, 0, 0); 44 } 45 document.documentElement.removeAttribute("class"); 46 } 47 image.src = imageURI; 48 } 49 </script> 50 </head> 51 <body onload="drawImageToCanvases('support/colors-8x16.png')"> 52 <canvas width="8" height="16" class="op_x-7"></canvas> 53 <canvas width="8" height="16" class="op_x13"></canvas> 54 <canvas width="8" height="16" class="op_x23"></canvas> 55 <canvas width="8" height="16" class="op_x50"></canvas> 56 <canvas width="8" height="16" class="op_x75"></canvas> 57 <canvas width="8" height="16" class="op_x88"></canvas> 58 <canvas width="8" height="16" class="op_x111"></canvas> 59 </body> 60 </html>