Start a new topic

How to verticaly center preloader when page is longer (higher) than the browser window

I stumbled upon an issue when using a preloader with logo inside.


If the page loading was longer(higher) than the browser window, logo and spinner were slightly decentered. Actually moved downwards.


Solution is to change preloder script line to look like this:

shortpoint._pTemplate = "<div style=\"position: absolute;top: 0;left: 0;height: 100vh;width: 100vw;\"><div style=\"display:table;width:100%;height:100%;\"><div style=\"display: table-cell;vertical-align: middle;\"><div style=\"margin-left: auto;margin-right:auto;\"><img class=\"shortpoint-preloader-logo\" src=\"/SiteAssets/RA-logo-badge.PNG\" /><div class=\"sk-circle\"><div class=\"sk-circle1 sk-child\"></div><div class=\"sk-circle2 sk-child\"></div><div class=\"sk-circle3 sk-child\"></div><div class=\"sk-circle4 sk-child\"></div><div class=\"sk-circle5 sk-child\"></div><div class=\"sk-circle6 sk-child\"></div><div class=\"sk-circle7 sk-child\"></div><div class=\"sk-circle8 sk-child\"></div><div class=\"sk-circle9 sk-child\"></div><div class=\"sk-circle10 sk-child\"></div><div class=\"sk-circle11 sk-child\"></div><div class=\"sk-circle12 sk-child\"></div></div></div></div></div></div>";

 

I have actualy added three more divs before the main div container (and closed them in the end of the script line:

<div style=\"position: absolute;top: 0;left: 0;height: 100vh;width: 100vw;\"><div style=\"display:table;width:100%;height:100%;\"><div style=\"display: table-cell;vertical-align: middle;\"><div style=\"margin-left: auto;margin-right:auto;\">

I hope this helps to someone.


 




1 person has this question
Login or Signup to post a comment