使用jQuery和CSS翻转卡片

时间:2015-06-30 08:07:33

标签: jquery html css

这是我的代码......当我点击翻转按钮时,一个div翻转并出现三个div。我的问题是我想在每个div延迟5秒后出现每个div。

像一个div然后5秒延迟然后第二个div然后5秒延迟和第三个div ..请解决我的问题。



function flip() {
  $('.card').toggleClass('flipped');
  axis: 'x'
}

.container {
      width: 200px;
      height: 260px;
      position: relative;
      border: 1px solid #ccc;
      -webkit-perspective: 800px;
      -moz-perspective: 800px;
      -o-perspective: 800px;
      perspective: 800px;
    }
    .card {
      width: 100%;
      height: 100%;
      position: absolute;
      -webkit-transition: -webkit-transform 1s;
      -moz-transition: -moz-transform 10s;
      -o-transition: -o-transform 10s;
      transition: transform 1s;
      -webkit-transform-style: preserve-3d;
      -moz-transform-style: preserve-3d;
      -o-transform-style: preserve-3d;
      transform-style: preserve-3d;
      -webkit-transform-origin: 50% 50%;
    }
    .card div {
      display: block;
      height: 100%;
      width: 100%;
      line-height: 260px;
      color: white;
      text-align: center;
      font-weight: bold;
      font-size: 140px;
      position: absolute;
      -webkit-backface-visibility: hidden;
      -moz-backface-visibility: hidden;
      -o-backface-visibility: hidden;
      backface-visibility: hidden;
    }
    .card .front {
      background: red;
    }
    .card .back {
      background: blue;
      -webkit-transform: rotateY(180deg);
      -moz-transform: rotateY(180deg);
      -o-transform: rotateY(180deg);
      transform: rotateY(180deg);
    }
    .card.flipped {
      -webkit-transform: rotateY(180deg);
      -moz-transform: rotateY(180deg);
      -o-transform: rotateY(180deg);
      transform: rotateY(180deg);
    }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button onclick="flip()">flip the card</button>
<section class="container">
  <div class="card">
    <div class="front">
      <label onclick="flip()">flip</label>
    </div>
    <div class="back">
      <label onclick="flip()">
        <div>
          <section class="container">
            <div class="card1">
              <div class="front1" style="color:gold !important">
                <label onclick="flip()">flip</label>
              </div>
              <div class="back1">
                <label onclick="flip()">flip</label>
              </div>
            </div>


          </section>
          <section class="container">
            <div class="card2">
              <div class="front2" style="color:gold !important">
                <label onclick="flip()">flip</label>
              </div>
              <div class="back2">
                <label onclick="flip()">flip</label>
              </div>
            </div>


          </section>

        </div>
      </label>
    </div>
  </div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

Javascript setTimeout可以做到这一点。

$(".card1").toggleClass("flipped");
window.setTimeout(function(){$(".card2").toggleClass("flipped");}, 5000);
window.setTimeout(function(){$(".card3").toggleClass("flipped");}, 10000);