I have a back-to-top arrow image that is fixed on the page when clicked. I want this arrow to be positioned within its parent div.
Below is the code snippet:
.relative {
position: relative;
}
.up {
float: right;
max-width: 3%;
display: block;
position: fixed;
top: 40%;
bottom: 30%;
right: 2%;
}
<section class="elements relative" id="about">
<a href="">
<img src="img/arrow-up.png" class="up" id="up-about" alt="" />
</a>
<h2>Who am I?</h2>
<p>Lots of text</p>
</section>
The current code makes the white arrow stay fixed on the screen as I scroll up or down the page. However, I only want it to remain within the "relative" section and not extend beyond. Can anyone suggest a simple solution for this issue? I hope my query is clear :)