Say I have a simple reveal.js slide like this:
<section>
<h2 class="fragment" data-fragment-index="1">first</h2>
<h2 class="fragment" data-fragment-index="2">second</h2>
<h2 class="fragment" data-fragment-index="1">first</h2>
</section>
I want the two "first" to be shown only in fragment 1 and then go back hidden in fragment 2, when "second" appears. How should I do that?
If you want to completely remove the space taken by the hidden element after it was shown, you can use the following CSS selector and properties:
Additionally if you don't want this behavior for other current-visible fragments, you can just add a custom class to your selector and HTML elements.
The
current-visible
class is what you're looking for, see the doc on fragments: https://github.com/hakimel/reveal.js/#fragmentsFor a demonstration of this class, see the general reveal.js demo: http://lab.hakim.se/reveal-js/#/20/1
Just to expand on dodo's answer. If you want to completely remove the element, but also want a bit of animation, you can do something like:
The above will fade out the element. You can also do something cool like:
This will make the item to "fall out" of the slide.