css - how calculate top property for fixed element -


:) when dont set top/left properties element fixed acccured?? please see sample code:

#fixed-menu{      background-color:#ba4444;      border-top: 5px solid #0892cd;      height: 60px;      position: fixed;      width: 100%;      z-index:9999;      box-shadow:rgb(128, 128, 128) 0px 5px 15px 0px;  }  #wrapper{      height:900px;      width:960px;      margin:0 auto;      background-color:yellow;      margin-top:100px;      }
<body>    <div id="fixed-menu"></div>    <div id="wrapper"></div>  <body>
above code,fixed-menu have 100px margin-top!!!!why????? ................... how calculated top property???

once element has been fixed position: fixed, 3 properties left, width , right determine horizontal position , size, relative window. (css uses more general word viewport; window example of viewport.)

you need @ 2 of 3 properties, i.e., left & width, right & width, or left & right. setting 1 of three, or none @ possible. in case, css use element's natural (“intrinsic”) size and/or position, needed, properties left @ default value ('auto').

the same holds trio top, height , bottom. need set @ 2 of them: top if want control distance top of window, bottom control distance bottom, , height if want specify fixed height.

i hope answers question. further reading can refer link


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -