I have this simple snippet:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body id="background-image"
style="background-image: url('background.jpg');" >
<div class="container">
wii jlkjkljkl fjkl jlkfsjlkfj klsajfkl sajkl jfklasj kfjsakl jlkfajs klfjlkasj fklasj klfjsakl lkfas
</div>
</body>
</html>
and the content of css.css is:
#background-image {
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: center center;
}
.container {
display: flex;
align-items: center;
justify-content: center;
}
I can't display the text in the center of the screen. It's centered horizontally, but not vertically. That is, I see a background image with the text centered horizontally at the top of the image. And I want to have the text right in the center.
What's wrong? I thought the combination of flex
and align-items:center
was enough to make this happen.