Skip to content

Instantly share code, notes, and snippets.

@bskaggs
Created February 28, 2017 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bskaggs/47ec990216c1bd02283a707aa0a20a8a to your computer and use it in GitHub Desktop.
Save bskaggs/47ec990216c1bd02283a707aa0a20a8a to your computer and use it in GitHub Desktop.
Persistent headers and footers on reveal.js slides
<!--include before initialize block-->
<script src="path/to/jquery.min.js"></script>
<script type="text/javascript">
Reveal.addEventListener( 'ready', function( event ) {
var banners = '<div id="banners"><header \/><footer \/><\/div>';
$('section').each(function (index, slide ) {
if ($(slide).children('section').length == 0) {
var bannerText = $(slide).closest('[data-banner]').data('banner');
if (bannerText) {
var background = $(slide.slideBackgroundElement);
background.append(banners);
background.find('header,footer').text(bannerText);
}
}
});
});
</script>
<!-- set data-banner values appropriately -->
<section data-banner="default">
<section>
<h2>Why a default?</h2>
<blockquote>
Sometimes you just need banners that all look the same.
</blockquote>
</section>
<section data-banner="something different">
<h2>But</h2>
<blockquote>
Sometimes they should be different.
</blockquote>
</section>
<section data-banner="">
<h2>Finally</h2>
<blockquote>
Sometimes you want them to be blank.
</blockquote>
</section>
</section>
header {
position: absolute;
top: 0;
width: 100%;
text-align:center;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
text-align:center;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment