I have made a simple background in Figma (1920×1600) and I want to place it as a hero image. But the problem is that the screen resolution can be 1920×800. I also want to place some content on the page. I want when user scrolls down the background would scroll until 1600 height and then it would scroll only the content.
Here’s the simple example:
I have an image from Figma image
then I import it as PNG export output
I wrote a CSS script to use it as a background:
body {
overflow-y: hidden;
margin: 0;
}
.background_container {
background-color: #444444;
background-image: url("https://i.sstatic.net/mL8LVRMD.png");
width: 100vw;
height: 100vh;
z-index: -1;
background-repeat: no-repeat;
background-size: 100% auto;
position: absolute;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="background_container">
</div>
<p class="txt"> Example1 </p>
<p class="txt"> Example2 </p>
<p class="txt"> Example3 </p>
<p class="txt"> Example4 </p>
<p class="txt"> Example5 </p>
<p class="txt"> Example6 </p>
<p class="txt"> Example7 </p>
<p class="txt"> Example8 </p>
<p class="txt"> Example9 </p>
<p class="txt"> Example1 </p>
<p class="txt"> Example2 </p>
<p class="txt"> Example3 </p>
<p class="txt"> Example4 </p>
<p class="txt"> Example5 </p>
<p class="txt"> Example6 </p>
<p class="txt"> Example7 </p>
<p class="txt"> Example8 </p>
<p class="txt"> Example9 </p>
<p class="txt"> Example1 </p>
<p class="txt"> Example2 </p>
<p class="txt"> Example3 </p>
<p class="txt"> Example4 </p>
<p class="txt"> Example5 </p>
<p class="txt"> Example6 </p>
<p class="txt"> Example7 </p>
<p class="txt"> Example8 </p>
<p class="txt"> Example9 </p>
<p class="txt"> Example1 </p>
<p class="txt"> Example2 </p>
<p class="txt"> Example3 </p>
<p class="txt"> Example4 </p>
<p class="txt"> Example5 </p>
<p class="txt"> Example6 </p>
<p class="txt"> Example7 </p>
<p class="txt"> Example8 </p>
<p class="txt"> Example9 </p>
<p class="txt"> Example1 </p>
<p class="txt"> Example2 </p>
<p class="txt"> Example3 </p>
<p class="txt"> Example4 </p>
<p class="txt"> Example5 </p>
<p class="txt"> Example6 </p>
<p class="txt"> Example7 </p>
<p class="txt"> Example8 </p>
<p class="txt"> Example9 </p>
<p class="txt"> Example1 </p>
<p class="txt"> Example2 </p>
<p class="txt"> Example3 </p>
<p class="txt"> Example4 </p>
<p class="txt"> Example5 </p>
<p class="txt"> Example6 </p>
<p class="txt"> Example7 </p>
<p class="txt"> Example8 </p>
<p class="txt"> Example9 </p>
</body>
</html>
and when I try to open this page I can see the top part of it but it does not let me to scroll it down even with the content:
2
Answers
This is the closest I could do… hope it helped you.
(make full screen to see the result)