Created
June 18, 2014 00:47
-
-
Save zoncoen/8911900331b2ac4b227f to your computer and use it in GitHub Desktop.
Print pdf with vertical centering contents in Reveal.js. Run this snippet on the Chrome dev tools just before exporting the PDF. (https://github.com/hakimel/reveal.js/issues/563)
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
function toArray(o) { | |
return Array.prototype.slice.call(o); | |
} | |
toArray( document.querySelectorAll( '.reveal .slides section' ) ).forEach(function(slide){ | |
var outerWrapper = document.createElement('div'); | |
outerWrapper.style.cssText = 'display:flex; align-items:center; height:100%'; | |
var wrapper = document.createElement('div'); | |
wrapper.style.width = '100%'; | |
outerWrapper.appendChild(wrapper); | |
toArray( slide.children ).forEach(wrapper.appendChild, wrapper); | |
slide.style.height = '100%'; | |
slide.appendChild(outerWrapper); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment