문제

Say I have a simple reveal.js slide like this:

 <section>
   <h1>Title</h1>
   <p >Text</p>
   <p class="fragment">Fragment</p>
 </section>

I'd like to change Text colour to red after Fragment appears on screen. How should I do it?

도움이 되었습니까?

해결책 2

It's not rather simple:

<section>
  <h1>Title</h1>
  <p id="postfragment">Text</p>
  <p class="fragment">Fragment</p>
</section>
...
<script>
Reveal.addEventListener('fragmentshown', function(event) {
   document.getElementById("postfragment").style.color="red"; 
});
</script>

다른 팁

You could simply do

<section>
  <h1>Title</h1>
  <p class="fragment highlight-red" data-fragment-index="1" >Text</p>
  <p class="fragment data-fragment-index="1"">Fragment</p>
</section>

That way, the red text and the "Fragment" text will always be in sync.

For those who want the highlight to actually appear after (rather than at the same time):

<section>
    <h1>Title</h1>
    <span class="fragment fade-in" data-fragment-index="1">
        <p class="fragment highlight-red" data-fragment-index="3">Text</p>
    </span>
    <p class="fragment" data-fragment-index="2">Fragment</p>
</section>

Here is a sample of how to do it with red blue and green

<p>Highlight <span class="fragment highlight-red">red</span> <span class="fragment highlight-blue">blue</span> <span class="fragment highlight-green">green</span></p>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top