Make a horizontal bar with fixed position, always at the top of screen while its height is unknown - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

Make a horizontal bar with fixed position, always at the top of screen while its height is unknown

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
 </head> <!--  ww  w.j av a2  s.c  o  m-->
 <body> 
  <div id="message_bar" style="float:left; width:100%; display:block;">
    Lorem ipsum dolor sit amet, conse 
  </div> 
  <div style="float:left; width:100%; height:95%; display:block; overflow:auto;"> 
   <div id="main_content" style="background:#fee;">
     Lorem ipsum dolor sit amet, consectetur a 
    <br>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi u 
    <ol> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
     <li>L</li> 
    </ol> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials