I created an HTML document where I show the image. Right now, these images can be scrolled up and down as we please, but how do I make the image appear and slightly move upwards when I scroll down and disappear when I scroll down too far?
The HTML Code I used is:
body,
html {
height: 100%;
margin: 0;
}
div.sticky {
position: sticky;
top: 0;
}
.bg {
background-attachment: fixed;
background-image: url("https://iso.500px.com/wp-content/uploads/2013/08/11834033-1170.jpeg");
min-height: 3000px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
table {
font-family: arial, sans-serif;
table-layout: fixed;
border-collapse: collapse;
width: 900px;
}
table.center {
margin-left: auto;
margin-right: auto;
}
td {
border: 1px solid #dddddd;
padding: 8px;
}
<div class="bg">
<div class="sticky">
<div style="text-align: center; font-size: 80px; font-weight: bold; color: white;">I Like Journeys.</div>
</div>
<div style="padding: 200px; text-align: center; font-size: 80px; font-weight: bold; color: white;">Travels</div>
<table class="center">
<tr>
<td align="center">
<a href="https://www.wikipedia.org/"><img border="0" alt="WTF" src="https://www.shutterstock.com/blog/wp-content/uploads/sites/5/2023/07/how_to_make_memes_with_stock_photos_cover.jpg?resize=1250,1120" width="270px" height="270px">
</td>
<td align="center">
<a href="https://www.wikipedia.org/"><img border="0" alt="WTF" src="https://www.shutterstock.com/blog/wp-content/uploads/sites/5/2023/07/how_to_make_memes_with_stock_photos_cover.jpg?resize=1250,1120" width="270px" height="270px">
</td>
<td align="center">
<a href="https://www.wikipedia.org/"><img border="0" alt="WTF" src="https://www.shutterstock.com/blog/wp-content/uploads/sites/5/2023/07/how_to_make_memes_with_stock_photos_cover.jpg?resize=1250,1120" width="270px" height="270px">
</td>
</tr>
</table>
</div>
How do I make the image appear and slightly move upwards when I scroll down and disappear when I scroll down too far?
A simple example would suffice.
Thank you all!
2
Answers
Your question was not totally cleared to me, but try this one if it’s same as you want, otherwise you can reach me out with clear picture.
There is a library that gives the effect you are trying to achieve.
Aos library
You can utilise this library by following procedure.
add css and js cdn
and initiate the library on page load.
Otherwise, if You do not to use any library then this can be done by javascript.