i want the canvas to fill the whole webpage under the heading, maybe with a small margin between the edge of the canvas and the edge of the window. but i can't get it to fill the screen and now the title is next to it instead of above it. any help is appreciated
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>shark?</title>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
}
.container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
}
canvas {
background-color: dodgerblue;
}
</style>
</head>
<body>
<div class="container">
<h1>shark?</h1>
<canvas></canvas>
</div>
</body>
</html>
Adding the property flex-direction: column;
to the container class to arrange the elements vertically.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>shark?</title>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
overflow: hidden; /* Prevent scrollbars */
}
.container {
display: flex;
flex-direction: column; /* Arrange elements vertically */
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
}
h1 {
margin-top: 20px; /* Add margin above the heading */
}
canvas {
background-color: dodgerblue;
margin: 10px; /* Add margin around the canvas */
flex: 1; /* Allow the canvas to fill available vertical space */
width: calc(100% - 20px); /* Account for margin */
}
</style>
</head>
<body>
<div class="container">
<h1>shark?</h1>
<canvas></canvas>
</div>
</body>
</html>