2017-12-25 18 views
1

ブートストラップ4 navでタブペインをアニメーション表示しようとしています。ここで ブートストラップ4タブアニメーション

は私のサンプルコードです:

.tab-pane { 
 
    transform: translateY(100%); 
 
    transition: transform 2s; 
 
} 
 
.tab-pane.active { 
 
    transform: translateY(0%); 
 
}
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" type="text/css"> 
 

 
<nav class="nav nav-tabs" id="myTab" role="tablist"> 
 
    <a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Home</a> 
 
    <a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</a> 
 
    <a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</a> 
 
</nav> 
 
<div class="tab-content" id="nav-tabContent"> 
 
    <div class="tab-pane active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab"> 
 
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 
    <div class="tab-pane" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab"> 
 
    type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 
    <div class="tab-pane" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab"> 
 
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 
</div>

は理論的には、各タブウィンドウ内のテキストは下から来る必要がありますが、私はタブを変更するたびに、私はそれを見つけます最終的な位置。間違いなく、私はこの設定について理解していないものがあります。誰かが私が間違っていることを教えてもらえますか?

+0

あなたは '4.0.0-beta'を参照することにより、あなたの例ではベータ1つのリソースを使用することに、注意してください。代わりに '4.0.0-beta.2'を使うべきです。 – dferenc

答えて

1

ここでの問題は、.activeクラスを持たない.tab-paneにはdisplay: none;が設定されていますが、その状態から移行するとCSSの移行は機能しません。

ですから、ここでは2つのオプションがあります。あなたはブートストラップがアクティブでないタブの処理方法をオーバーライドすることができ、代わりに表示プロパティを使用しての、あなたが表示するように可視性プロパティsay- -LEt年代を使用することができます/非表示

  • をタブ。 display:blockが強制されていることを確認してください。
  • css transitionではなく、キーフレームのあるcss animationを使用して簡単に解決できます。前者のソリューションは、ディスプレイで動作します。なし。以下の例は、この例です。

.tab-pane.active { 
 
    animation: slide-down 2s ease-out; 
 
} 
 

 
@keyframes slide-down { 
 
    0% { opacity: 0; transform: translateY(100%); } 
 
    100% { opacity: 1; transform: translateY(0); } 
 
}
<nav id="myTab" class="nav nav-tabs" role="tablist"> 
 
    <a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Home</a> 
 
    <a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</a> 
 
    <a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</a> 
 
</nav> 
 

 
<div class="tab-content" id="nav-tabContent"> 
 
    <div class="tab-pane active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab"> 
 
     Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 

 
    <div class="tab-pane" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab"> 
 
     type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 

 
    <div class="tab-pane" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab"> 
 
     It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 
</div> 
 

 

 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>

関連する問題