position:static;, position:absolute;, and position:relative; are the alternatives to position:fixed;. There isn't a definitive opposite, because relative, absolute, static, and fixed have different properties to behave differently.
Take a look at this article:
http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/
Answer from void main on Stack Overflowposition:static;, position:absolute;, and position:relative; are the alternatives to position:fixed;. There isn't a definitive opposite, because relative, absolute, static, and fixed have different properties to behave differently.
Take a look at this article:
http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/
"Default value: static" (seems an opposite to fixed as it shows where is placed and scrolls with the content)
position: static;
Probably you should edit your question and use "which are the alternatives of position: fixed"!
When is 'affix' a more appropriate choice than 'fix'?
Although the words affix and fix have much in common, affix implies an imposing of one thing on another by gluing, impressing, or nailing.
// affix your address label here
When might 'attach' be a better fit than 'fix'?
The words attach and fix can be used in similar contexts, but attach suggests a connecting or uniting by a bond, link, or tie in order to keep things together.
// attach the W-2 form here
How is the word 'fix' distinct from other similar verbs?
Some common synonyms of fix are affix, attach, and fasten. While all these words mean "to make something stay firmly in place," fix usually implies a driving in, implanting, or embedding.
// fixed the stake in the ground
To make a element sticky at the top you add this:
element{
position:sticky;
top:0;
}
To make the element sticky at the bottom you need to replace top:0; with bottom:0;
element{
position:sticky;
bottom:0;
}
The trick is to take advantage of the "stickiness" being dependent on the containing block. As MDN puts it:
...at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
So you need the containing block to start where you want the sticky element to start being sticky (in your case, at the top of the page), and to end where you want the sticky element to stop being sticky (in the footer).
It gets a little tricky if you wanted it to get "unstuck" somewhere in the middle of a footer (like I was needing), but it's totally doable. Here's a basic example where I "split" the footer into top and bottom elements to allow the button to appear like it's getting unstuck inside the footer (see at JS Fiddle).
HTML
<div class="sticky-wrapper">
<main>
Scroll down
</main>
<footer class="top">
</footer>
<div class="sticky">
<button>Button</button>
</div>
</div>
<footer class="bottom">
</footer>
CSS
main {
min-height: 200vh;
}
.sticky {
position: sticky;
bottom: 50px;
height: 0;
padding: 0 16px;
}
footer {
background: #808080;
}
footer.top {
height: 16px;
}
footer.bottom {
height: 100px;
}