jquery - Center a div in a horizontal scrolling site -


wonder if advise on best way center div in middle of screen of horizontal scrolling site.

i want header stay positioned in center of screen rest of site scrolls. i'd set left , right margins zero, width set full scroll width imagine i'll need jquery trickery find window width first of all?

any advice gratefully received!

can done css, no need javascript.

<div class="page">     <div class="header"></div> </div>  .page{     width:2000px;     height:500px; } .header{     width:300px;     height:100px;     background-color:red;     position:fixed;     top:0;     left:50%;     margin-left:-150px; /* negative half width */  } 

check working example @ http://jsfiddle.net/zecax/


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -