I am facing an issue with a div that has specific dimensions (
height:x; width:y; overflow:auto;
) and displays the content of an article. The problem arises when the content exceeds the div's limits, causing a scrollbar to appear for navigation.
Within this div, there is a 'close' link styled with
position: absolute; top: 20px; right: 20px;
, which features an 'x' to close the div using jQuery and animations. However, as I scroll through the article, the 'x' also moves along with the content, which is not the desired behavior. I want the 'x' to stay fixed in its position regardless of scrolling.
I attempted changing the position attribute to 'fixed', but this anchored the 'x' to the body of the page rather than within the div itself. Is there a solution to overcome this challenge without relocating the div outside the primary content?
<div class="box1">
<a data-type="close">X</a>
<div class="inner">
//content//
</div>
</div>