Skip to content

Instantly share code, notes, and snippets.

@benknight
Last active January 3, 2016 23:19
Show Gist options
  • Save benknight/8534607 to your computer and use it in GitHub Desktop.
Save benknight/8534607 to your computer and use it in GitHub Desktop.
Yelp Fixed Header (Plain)
/* Prevent "jump" in content offset */
.fixed-header body {
padding-top: 77px;
}
.fixed-header .app-header {
position: fixed;
top: 0;
width: 100%;
}
/* Make location dropdown and autocomplete positioned according to the header again */
.fixed-header #dropper,
.fixed-header .autocomplete_choices {
position: fixed !important;
top: 40px !important;
}
(function() {
var html_classes = document.body.parentNode.classList;
html_classes.add('fixed-header');
})();
<body>
<head>
<meta charset="utf-8">
<title>Fixed Header</title>
</head>
Drag me into the bookmarks bar:<br>
<a href="javascript:(function(){var gist_id='8534607';var css=[];var js=[];var applyCSS=function(){for(var x in css){var style=document.createElement('style');style.innerHTML=css[x];document.head.appendChild(style);}};var applyJS=function(){for(var x in js){var script=document.createElement('script');script.innerHTML=js[x];document.body.appendChild(script);}};var xhr=new XMLHttpRequest();xhr.open('GET','https://api.github.com/gists/'+gist_id,true);xhr.onload=function(){var data=JSON.parse(this.responseText);for(var file in data.files){if(data.files[file].language=='CSS'){css.push(data.files[file].content);}if(data.files[file].language=='JavaScript'){js.push(data.files[file].content);}}applyCSS();applyJS();};xhr.onerror=function(){console.log('Failed to load Gist: '+request.gist);};xhr.send();}());">
Fixed Header (Plain)
</a>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment