javascript - Fixed header/footer keep vertical scroll bar on top? -


i have partly transparent fixed footer , header scrolling content: https://jsfiddle.net/ru8jgxg9/

what changes jsfiddle need made keep vertical scroll bar on top when there overflow content (but keep scroll bar whole height of window too)?

i notice stackoverflow.com seems able it:

enter image description here

enter image description here

html {   height: 100%; }  body {   height: 100%; }  /* fixed header */ .dvtabletop {   display: table;   width: 100%;   border-style: solid;   border-width: 0px 0px 2px 0px;   border-color: #000000;   top: 0px;   height: 50px;   position: fixed;   left: 0;   right: 0;   opacity: 0.7;   background-color: red;   z-index: 1030; }  /* scrollable content */ .dvcontentcontainer1 {   position: fixed;   top: 0;   bottom: 0;   padding-top: 30px;   overflow: auto;   left: 0;   right: 0; }   /* fixed footer */ .dvfootercontainer1 {   position: fixed;   height: 50px;   background-color: yellow;   bottom: 0;   left: 0;   right: 0;   opacity: 0.7; } 

your fixed header , footer needs inside scrolling container. currently, they're outside content container , overlap , scrollbar.

also, content container can't have position: fixed, otherwise fight other fixed elements position , cause overlaps. fixed elements relative document, not container.

below working example.

body {    margin: 0;    padding: 0;        font-family: arial, helvetica, san-serif;  }    .content {    height: 1000px;        background: linear-gradient(45deg, blue, red);  }    .header {    position: fixed;    top: 0;    left: 0;    right: 0;    height: 50px;        background: rgba(0, 255, 0, 0.5);  }    .footer {    position: fixed;    bottom: 0;    left: 0;    right: 0;    height: 50px;        background: rgba(0, 255, 0, 0.5);  }
<div class="content">    <div class="header">header</div>    <div class="footer">header</div>  </div>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -