HTML Code:
<!DOCTYPE html>
<html>
<head></head>
<body>
<link rel="stylesheet" type="text/css" href="style.css">
<div class="sheet" style="width:80%;max-width:1024px;height:400px;"></div>
</body>
</html>
CSS Code:
html,
body {
min-height: 100%;
margin: 0;
padding: 0
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.sheet {
background-color: red
}
What I expected to see was a red rectangle floating in the middle of the screen but what I get is the rectangle being at the top-middle.
It never worked in FF, it worked in chrome before adding the DOCTYPE tag but after that it no longer works in chrome either.
What does work is when I use height
instead of min-height
but I don't want to pin down the height value to the size of the screen since I may need it when containers long enough to scroll come into play.