html - Only Margin-top is working but not top -


i'm trying align login page css. however, have problem between 2 property margin-top , top. margin-top tend push login page based on first element, while top position of login page. therefore, cannot use margin-top in media query codes. unfortunately, top isn't working well

this how added top property in css

#loginpage { position:absolute; width:100%; top:-42%; } 

which not working.

only working

margin-top:-20%; 

above loginpage, there's slideshow header , twitterbootstrap navbar

#twitterbootstrap {     position: relative; }  #slideshowhome {     position: absolute;     left: 0%;     width: 100%;     top: 6%;     height: 20%; } 

this loginpage

 <div id="loginpage">     <table id="loginpage1" width="100%">     <tr>         <td>             <h2>login</h2>             <br />         </td>     </tr>      <tr>         <td>           <b>  username : </b> <asp:textbox id="txtusername" runat="server"></asp:textbox>             <br />             <br />         </td>     </tr>      <tr>          <td>            <b> password : </b> <asp:textbox id="txtpassword" runat="server" textmode="password" ></asp:textbox>             <br />             <br />         </td>     </tr>  </table> </div> 

this twitterbootstrap , slideshow header

 <div id="slideshowhome">  <img src="image/s1.jpg" name="slide" style="width:100%; height:150%"> 
</div> <div id="twitterbootstrap"> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner">     <div class="container">         <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">             <span class="icon-bar"></span>             <span class="icon-bar"></span>         </a>         <a class="brand" href="#">ipolice's menu</a>         <div class="nav-collapse">             <ul class="nav">                 <li class="divider-vertical"></li>                 <li><a href="login.aspx">login</a></li>                 <li class="divider-vertical"></li>                 <li><a href="recoverpassword.aspx">recover password</a></li>                 <li><a href="https://www.facebook.com/singaporepoliceforce?ref=ts&fref=ts"><img src="image/facebook.jpg" style="width:100px; height:30px"></a></li>                 <li><a href="https://twitter.com/singaporepolice"><img src="image/twitter.jpg" style="width:100px; height:30px"></a></li>             </ul>         </div>     </div> </div> </div> </div> 

therefore, may ask why margin-top changes position not top?

a value of top in percent based on height of containing block - see http://www.w3.org/tr/css21/visuren.html#position-props - while margin-top in percent based on width of containing block - see http://www.w3.org/tr/css21/box.html#margin-properties - causing difference in size.

so if guess correct , login page contains absolutely positioned divs, containing block, body, functionally empty , doesn't have height.
have standard width of 100% of window, that's why top-margin works not top.

solution: give container height explicitly.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -