My page is 2x the height of the screen (the size depends on another element on the page). I want to show an absolutely positioned SPAN in the middle of the screen, regardless of the scroll position.
I apply the following style when I click the button, however, if I scroll all the way down, the element is displayed at the top of the page, as it counts 50% of the top of the whole page.
.Centered {
width: 100%;
position: absolute;
top: 50%;
left: 45%;
}
How to place an element in the middle of the page based on the scroll potion at the click of a button?
Thanks.
source
share