Skip to content

Instantly share code, notes, and snippets.

@skywalker-nick
Created October 25, 2023 08:30
Show Gist options
  • Save skywalker-nick/4568f9cfcc9ef8d55254a256fc9d8b60 to your computer and use it in GitHub Desktop.
Save skywalker-nick/4568f9cfcc9ef8d55254a256fc9d8b60 to your computer and use it in GitHub Desktop.
Reveal.js footer and header for every page
<style type="text/css">
/* 1. Style header/footer <div> so they are positioned as desired. */
#header-left {
position: absolute;
top: 0%;
left: 0%;
}
#header-right {
position: absolute;
top: 0%;
right: 0%;
}
#footer-left {
position: absolute;
bottom: 0%;
left: 0%;
}
</style>
<!-- 2. Create hidden header/footer <div> -->
<div id="hidden" style="display:none;">
<div id="header">
<div id="header-left">HEADER-LEFT</div>
<div id="header-right">HEADER-RIGHT</div>
<div id="footer-left">FOOTER-LEFT</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
// 3. On Reveal.js ready event, copy header/footer <div> into each `.slide-background` <div>
var header = $('#header').html();
if ( window.location.search.match( /print-pdf/gi ) ) {
Reveal.addEventListener( 'ready', function( event ) {
$('.slide-background').append(header);
});
}
else {
$('div.reveal').append(header);
}
</script>
<!-- Code: this can be copy-pasted into the end of a reveal.js file (right before the end </body> tag) -->
@skywalker-nick
Copy link
Author

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