Source code

Revision control

Copy as Markdown

Other Tools

<title>Content-DPR: various elements</title>
<link rel="author" title="Noam Rosenthal" href="">
<meta name="assert" content="Assert that content-dpr is taken into account for images in all relevant elements (input/canvas/svg/video-poster)">
.row {
display: flex;
.row > * {
object-fit: none;
object-position: top left;
margin: 5px;
width: 100px;
height: 100px;
background: yellow;
document.addEventListener("DOMContentLoaded", () => {
const canvas = document.getElementById('canvas')
const image = new Image()
image.onload = () => {
const ctx = canvas.getContext('2d')
ctx.drawImage(image, 0, 0, 50, 50)
image.src = "resources/square.png"
<p>There following green boxes should all be 50px by 50px (cover 25% of the yellow boxes)</p>
<div class="row">
<img src="resources/square.png" width="50" height="50" />
<video poster="resources/square.png" width="50" height="50"></video>
<svg xmlns="" ><image href="resources/square.png" width="50" height="50" /></svg>
<input type="image" src="resources/square.png" width="50" height="50" />
<canvas id="canvas" width="100" height="100">