Reveal.js: Per slide vertical centering

Created on 12 Jun 2015  路  13Comments  路  Source: hakimel/reveal.js

Most of my slide are not vertically centered (I use center: false, option). How can I ask reveal.js to vertically center only one slide (by JS or CSS).

Thank you

question

Most helpful comment

Hey @hadim this should be possible by adding the class "center" to any slide you want vertically centred.

All 13 comments

Hey @hadim this should be possible by adding the class "center" to any slide you want vertically centred.

Thank you +1

How can you add the "center" class to a slide in your markdown code ?

thanks for your response !

You can see this example from the readme:

<section data-markdown>
    <script type="text/template">
    <!-- .slide: class="center" -->
        Markdown content
    </script>
</section>

Or just add the class directly as well:

<section data-markdown class="center">
    <script type="text/template">
        Markdown content
    </script>
</section>

Thank for the response...
but I need to apply this style to some specific slides, and my slides are divided in chapters I specific md files.
One slide is delimited by --- from the other
so I don't understand how to proceed in my case.

My index.html links all chapters using:

<section>
  <section data-markdown="/myfolder/mychapter.md" data-separator="^\n---\n" data-vertical="^\n\n">
Markdown body of a slide here ...
  </section>
</section>

You can try placing the <!-- .slide: class="center" --> after each --- for each slide.

Strange, I've placed this code immediately after ---, and the generated html contains

<section data-markdown="" data-markdown-parsed="true" class="center present" style="top: 0px; display: block;"><!-- -->
<h2 id="le-jeu-de-test">Le jeu de test</h2>
<p>test</p>
</section>

But my text isn't vertically centered...

The slide should be vertically centred, not too sure how to help you with that anymore.

is center a standard css style ?
I can't find a specific css rule defined in provided css files...

The center class is used in JS to indicate that the slide should be vertically centred. See https://github.com/hakimel/reveal.js/blob/713702a0ab81d1756a30e6c14ae49afd42135541/js/reveal.js#L1650-L1659.

ok, thank you very much for your help !

Ok, I've tried on a new presentation, and the slides is centered...
But it is normal that both the title and the text are centered ? I'd like to center only my text, the title of the slide should remain on the top !

Thank you !

There isn't a built in way to do that, you'll have to manually figure out the CSS and styles to make it work. The Reveal.js center will only center the whole slide.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MurhafSousli picture MurhafSousli  路  5Comments

gre picture gre  路  5Comments

OscarDeDios picture OscarDeDios  路  3Comments

lichtner picture lichtner  路  4Comments

nedbat picture nedbat  路  3Comments