Skip to content

Instantly share code, notes, and snippets.

Created May 29, 2013 13:43
Show Gist options
  • Save alisdair/5670341 to your computer and use it in GitHub Desktop.
Save alisdair/5670341 to your computer and use it in GitHub Desktop.
Kill sticky headers.
(function () {
var i, elements = document.querySelectorAll('body *');
for (i = 0; i < elements.length; i++) {
if (getComputedStyle(elements[i]).position === 'fixed') {
Copy link

alisdair commented May 29, 2013

Copy link

for (var i in elements.length) { !
For Each > For.

Copy link

Brilliant on mobile. Adding a bookmarklet is a bit of a pain on iOS; I used these directions: I had no problem copying the formatted JS text from the article and prefixing it with "javascript:" when editing the bookmark.

Copy link

terwanerik commented Jun 27, 2017

elements[i].style.position = 'absolute' isn't that better? So you don't have to refresh the page if your nav was sticky

Copy link

You might also want to check for position sticky since that has decent support now.

Copy link

yes, what @terwanerik said, but I'd suggest 'static' instead of absolute.

Copy link

mgiraldo commented Aug 2, 2017

extension doesn't work in twitter :\

Copy link

nborrmann commented Aug 22, 2017

This also kills headers that use position: sticky:

    if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) {

(line 5)

Copy link

Is it at all possible to adapt this to a Stylus/Stylish script?

Copy link

marty60 commented May 13, 2019

Mozilla broke the code I was using to make this a standalone button. Had to install the kill sticky addon to get it back

The bookmarklet still works fine so the war on sticky/fixed objects continues.

Copy link

nbeaver commented Jul 2, 2019

Copy link

tejasanilshah commented Jul 27, 2020

Loved the sticky header on the new site. Loved killing it even more.
Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment