html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!-- created by rose -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SVG Image Gallery...</title>
</head>
<body>
<h3>SVG Image Gallery...</h3>
<div class="container">
<canvas id="canvas"></canvas>
</div>
<script>
// created by rose
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
function resizeCanvas() {
let width = Math.min(window.innerWidth * 0.9, 400);
let height = width * 1.5;
canvas.width = width;
canvas.height = height;
}
resizeCanvas();
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* created by rose */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: white;
height: 100vh;
}
.container {
position: relative;
width: 90vw;
max-width: 400px;
height: auto;
}
canvas {
background-color: white;
display: block;
width: 100%;
js
js
1
alert("if my images is not fetch then you use your images ok!!")
BROWSER
Console
Uruchom