Make Canvas fill the parent container on Wasm

This commit is contained in:
Héctor Ramón Jiménez 2024-02-20 02:51:47 +01:00
parent 8a86ef14e3
commit 0c7f4eaab5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 6 additions and 2 deletions

View file

@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" style="height: 100%">
<head>
<meta charset="utf-8" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tour - Iced</title>
<base data-trunk-public-url />
</head>
<body>
<body style="height: 100%; margin: 0">
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="z" data-bin="tour" />
</body>
</html>

View file

@ -159,6 +159,10 @@ where
use winit::platform::web::WindowExtWebSys;
let canvas = window.canvas().expect("Get window canvas");
let _ = canvas.set_attribute(
"style",
"display: block; width: 100%; height: 100%",
);
let window = web_sys::window().unwrap();
let document = window.document().unwrap();