0

I have some divs as follows.

<body>
    <div class="main">
        <div class="page1 active">
            <p>Page1</p>
            <button id="btn-about">Page2</button>
        </div>
        <div class="page2">
            <p>Page2</p>
        </div>
    </div>
</body>

The pages are hidden by default unless they have the active class. To display a new page, I remove all active classes within the div which has class main and then add the active class to the page I want, for e.g page 2.

With something like this

$("#btn-about").click(

    function(e) {
       e.preventDefault();
       $(".main div").removeClass("active");
       $(".main .page-2").addClass("active");

    }

); 

And then it becomes something like this:

<div class="page2 active">
    <p>Page2</p>
</div>

It works fine but now I want, using CSS3, to hide or show the pages with certain effects. Sliding Up, Sliding Down, Sliding Left, Sliding Right or Fades.

I am a newbie regarding CSS3 and would appreciate all the help.

1

2 Answers 2

1

For CSS animations you can use the transition: style, for a sequence of transitions combine it with transition-delay:

Here are some good places to start researching:

And this tutorial has the transitions you mentioned:

Sign up to request clarification or add additional context in comments.

Comments

0

I think you can look at

  • Effeckt.css, which is a great project from the html5-boilerplate team. But as they say "Work in Progress! Not quite ready for prime-time"
  • Animate.css which is more production ready but less ambitious

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.