html - Place an absolute element in bottom of a container with overflow: auto -


i have logo should positioned in bottom of fixed container. works ok position: absolute; if add overflow-y: auto; fixed container , add content doesn't fit viewport height, logo stick bottom of viewport, not bottom of fixed container, overlapping content.

<div class="foo">     <div class="content"></div>     <div class="logo-in-the-bottom">logo</div> </div>  .foo {     position: fixed;     top: 0; left: 0;     width: 100%; height: 100%;     background: gray;     overflow-y: auto; } .content {     height: 1000px; } .logo-in-the-bottom {     position: absolute;     bottom: 10px; left: 0;     color: white } 

http://jsfiddle.net/1aoah1r5/

how stick bottom of fixed container no matter content height?

try this:

depending on content:

.foo {      position: fixed;      top: 0; left: 0;      width: 100%; height: 100%;      background: gray;      overflow-y: auto;  }  .content {      min-height: 100%;      height: 1000px;      position: relative;  }  .logo-in-the-bottom {      position: absolute;      bottom: 10px; left: 0;      color: white  }
<div class="foo">      <div class="content">          <div class="logo-in-the-bottom">logo</div>      </div>  </div>

for future references:

sticky version:

.foo {      position: fixed;      top: 0; left: 0;      width: 100%; height: 100%;      background: gray;  }  .container {      width: 100%; height: 100%;      overflow-y: auto;  }    .content {      height: 1000px;  }  .logo-in-the-bottom {      position: absolute;      bottom: 10px;       left: 0;      color: white  }
<div class="foo">      <div class="container">          <div class="content">          </div>      </div>      <div class="logo-in-the-bottom">logo</div>  </div>

you need add container overflow inside .foo. why ? way .foo fixed , absolute relative fixed position, not content because .container 1 overflowing.

on bottom:

.foo {      position: fixed;      top: 0; left: 0;      width: 100%; height: 100%;      background: gray;      overflow-y: auto;  }  .content {      height: 1000px;  }  .logo-in-the-bottom {      position: relative; //no need absolute      color: white  }
<div class="foo">      <div class="content">        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>        <p>lorem ipsum </p>          <div class="logo-in-the-bottom">logo</div>      </div>  </div>


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -