Created
February 28, 2017 04:16
-
-
Save bskaggs/47ec990216c1bd02283a707aa0a20a8a to your computer and use it in GitHub Desktop.
Persistent headers and footers on reveal.js slides
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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