html - div below another absolute positioned div -


i have problem div below div has "position: absolute". need make footer appear under container div footer appearing somewhere behind container. screen: (div green background footer) enter image description here

html:

<div class="horni-panel">     <div class="logo">         zhlednuto.cz     </div>      <div class="menu">         home, atd.     </div>  </div>  <!-- mini pozadi --> <div class="minipozadi">     ahoj </div>  <!-- hlavni obsah --> <div class="container">   lorem ipsum dolor sit amet. x 40 </div> 

css:

@font-face {     font-family: lato-bold;     src: url(fonts/lato-bold.ttf); }  body {     font-family: myriad pro;     font-size: 17px;     color: #a1a8af;     background-color: #34495e; }  .horni-panel {     border-top: 8px solid #34495e;     position:absolute;     top:0;     left:0;     right:0;     height: 77px;     width: 100%;     background-color: #ffffff; }  .logo {     color: #34495e;     font-family: lato-bold;     font-size: 33px; }   .minipozadi {     height: 282px;     width: 100%;     background-image: url(img/bg.jpg);     background-size: cover;     background-repeat: no-repeat;     margin: 0 auto;     position:absolute;     top: 85px;     left:0;     right:0;     z-index:1;     text-align:center;     font-size:30px; }  .container {     padding: 20px;     margin: 0 auto;     border-radius: 5px;     z-index: 100;     position:absolute;     top:0;     right:0;     left:0;     margin-top:266px;     width: 70%;     background-color: #ffffff;     border-rder-radius: 5px; }  .footer { margin: 0 auto;     width: 100%;     height: 480px;     background-color: green; } 

absolutely positioned elements removed flow of document. footer moves because container not part of flow. need either use relative positioning on both, or absolute positioning both , set specific top , left values.

alternatively set top margin on footer makes drop enough positioned below container.

you need @ css. there several redundant properties possibly conflicting.

body {     font-family: arial;     font-size: 17px;     color: #a1a8af;     background-color: #34495e; }  .horni-panel {     border-top: 8px solid #34495e;     position:absolute;     top:0; left:0;     height: 77px;  width: 100%;     background-color: #ffffff; }  .logo {     color: #34495e;     font-family: lato-bold;     font-size: 33px; }  .minipozadi {     height: 100px;  width: 100%;     position:absolute;     background-color: blue;     top: 85px;   left:0;     z-index:1;     text-align:center;     font-size:30px; }  .container {     padding: 20px;     border-radius: 5px;     z-index: 100;     position:relative;     margin: 0 auto;     top: 120px;     width: 70%;     background-color: #fea; }  .footer {     margin-top: 120px;     width: 100%;     height: 80px;     background-color: green; } 

here in fiddle removed of redundant css , used position:relative on container div instead of absolute. margin-top property on footer needs greater or equal top property on container in order stay below it.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -