javascript - Bootstrap Tabs Animation -
i tried animate bootstrap tabs adding css class it's not working, simple idea animate tabs content based on bootstrap class .active, problem transition not working:
.tab-content .tab-pane h3 { opacity: 0; -moz-transform: translate(-10px, -10px) rotate(30deg); -ms-transform: translate(-10px, -10px) rotate(30deg); -o-transform: translate(-10px, -10px) rotate(30deg); -webkit-transform: translate(-10px, -10px) rotate(30deg); transform: translate(-10px, -10px) rotate(30deg); transition: .5s ease-in-out; } .tab-content .active h3 { opacity: 1; transform: translate(0); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <div id="extab1" class="container"> <ul class="nav nav-pills"> <li class="active"> <a href="#1a" data-toggle="tab">overview</a> </li> <li><a href="#2a" data-toggle="tab">using nav-pills</a> </li> <li><a href="#3a" data-toggle="tab">applying clearfix</a> </li> <li><a href="#4a" data-toggle="tab">background color</a> </li> </ul> <div class="tab-content clearfix"> <div class="tab-pane active" id="1a"> <h3>content's background color same tab</h3> </div> <div class="tab-pane" id="2a"> <h3>we use class nav-pills instead of nav-tabs automatically creates background color tab</h3> </div> <div class="tab-pane" id="3a"> <h3>we applied clearfix tab-content rid of gap between tab , content</h3> </div> <div class="tab-pane" id="4a"> <h3>we use css change background color of content equal tab</h3> </div> </div> </div>
you cannot use transition between display:block
, display:none
, need set display:block
.tab-content>.tab-pane
.
#extab1 .tab-content { overflow: hidden; } #extab1>.tab-content>.tab-pane { display: block; position: absolute; overflow: hidden; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <style> .tab-content .tab-pane h3 { opacity: 0; -moz-transform: translate(-10px, -10px) rotate(30deg); -ms-transform: translate(-10px, -10px) rotate(30deg); -o-transform: translate(-10px, -10px) rotate(30deg); -webkit-transform: translate(-10px, -10px) rotate(30deg); transform: translate(-10px, -10px) rotate(30deg); transition: .5s ease-in-out; } .tab-content .active h3 { opacity: 1; transform: translate(0); } #extab1 .tab-content { overflow: hidden; } #extab1>.tab-content>.tab-pane { display: block; position: absolute; overflow: hidden; } </style> <div id="extab1" class="container"> <ul class="nav nav-pills"> <li class="active"> <a href="#1a" data-toggle="tab">overview</a> </li> <li><a href="#2a" data-toggle="tab">using nav-pills</a> </li> <li><a href="#3a" data-toggle="tab">applying clearfix</a> </li> <li><a href="#4a" data-toggle="tab">background color</a> </li> </ul> <div class="tab-content clearfix"> <div class="tab-pane active" id="1a"> <h3>content's background color same tab</h3> </div> <div class="tab-pane" id="2a"> <h3>we use class nav-pills instead of nav-tabs automatically creates background color tab</h3> </div> <div class="tab-pane" id="3a"> <h3>we applied clearfix tab-content rid of gap between tab , content</h3> </div> <div class="tab-pane" id="4a"> <h3>we use css change background color of content equal tab</h3> </div> </div> </div>
Comments
Post a Comment