Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Depending on if your site is using a fixed size as a resolution or not would be the solution to the issue.</p> <p>If you are using a fixed size then use the left property to center it since you are fixing the position.</p> <p>If you expand your site depending on user's resolution you will need to use javascript to get the position of the screen. Using an x and y offset. Below is some sample code to get dead center you would need to alter the y offset to the top of the screen to get the effect you want but it's a good starting point and I'm sure you can build on it to get what you want.</p> <pre><code>function showdeadcenterdiv(Xwidth,Yheight,divid) { // First, determine how much the visitor has scrolled var scrolledX, scrolledY; if( self.pageYoffset ) { scrolledX = self.pageXoffset; scrolledY = self.pageYoffset; } else if( document.documentElement &amp;&amp; document.documentElement.scrollTop ) { scrolledX = document.documentElement.scrollLeft; scrolledY = document.documentElement.scrollTop; } else if( document.body ) { scrolledX = document.body.scrollLeft; scrolledY = document.body.scrollTop; } // Next, determine the coordinates of the center of browser's window var centerX, centerY; if( self.innerHeight ) { centerX = self.innerWidth; centerY = self.innerHeight; } else if( document.documentElement &amp;&amp; document.documentElement.clientHeight ) { centerX = document.documentElement.clientWidth; centerY = document.documentElement.clientHeight; } else if( document.body ) { centerX = document.body.clientWidth; centerY = document.body.clientHeight; } // Xwidth is the width of the div, Yheight is the height of the // div passed as arguments to the function: var leftoffset = scrolledX + (centerX - Xwidth) / 2; var topoffset = scrolledY + (centerY - Yheight) / 2; // The initial width and height of the div can be set in the // style sheet with display:none; divid is passed as an argument to // the function var o=document.getElementById(divid); var r=o.style; r.position='absolute'; r.top = topoffset + 'px'; r.left = leftoffset + 'px'; r.display = "block"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload