Here is a slightly more complex answer that also works with the pdf export version:
Add elements to slide-background <div> (instead of section , slides or reveal ). This <div> is dynamically generated, so we must wait for the Reveal.js ready event. When printing, there is a slight delay, followed by unnecessary animation of the headers and footers, but all headers and footers are displayed in PDF format as desired.
Pseudo Code:
- Header header / footer <div> therefore they are located as desired.
- Create hidden header / footer <div>
- In the Reveal.js ready event, copy header / footer <div> to each
.slide-background <div>
Code:, this can be copied to the end of the opens.js file (right before the </body> tag):
<style type="text/css"> #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> <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>
Leftium
source share