I have included a code snippet, I'm trying to position the header and footer so that it is inside of the .main
div.
I have no idea why this isn't working. Instead it is spanning across the whole of the viewport.
In this particular layout I can't determine the left position of the parent without JavaScript and I wish to keep it at CSS.
The header and footer should stay in the same place as they are when scrolled.
.main {
position: absolute;
left: 60px;
right: 0px;
top: 0px;
height: 50000px;
background-color: #09f;
}
.parent {
position: relative:
width: 100%;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #f00;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #f00;
}
<div class="main">
<div class="parent">
<div class="header">
<h3>header</h3>
</div>
<div class="footer">
<h3>footer</h3>
</div>
</div>
</div>
Thanks for any help in advance, Jamie