HTML5+CSS3价格表翻转切换动画

2025-11-05 10:08:19

1、新建html文档。

HTML5+CSS3价格表翻转切换动画

2、书写hmtl代码。

<div class="pricing-container">

 <div class="pricing-switcher">

  <p class="fieldset">

   <input type="radio" name="duration-1" value="monthly" id="monthly-1" checked>

   <label for="monthly-1">Monthly</label>

   <input type="radio" name="duration-1" value="yearly" id="yearly-1">

   <label for="yearly-1">Yearly</label>

   <span class="switch"></span>

 </div>

 <ul class="pricing-list bounce-invert">

  <li>

   <ul class="pricing-wrapper">

    <li data-type="monthly" class="is-visible">

     <header class="pricing-header">

      <h2>Basic</h2>

      <div class="price"> <span class="currency">$</span> <span class="value">30</span> <span class="duration">mo</span> </div>

     </header>

     <div class="pricing-body">

      <ul class="pricing-features">

       <li><em>5</em> Email Accounts</li>

       <li><em>1</em> Template Style</li>

       <li><em>25</em> Products Loaded</li>

       <li><em>1</em> Image per Product</li>

       <li><em>Unlimited</em> Bandwidth</li>

       <li><em>24/7</em> Support</li>

      </ul>

     </div>

     <footer class="pricing-footer"> <a class="select" href="#">Sign Up</a> </footer>

     </div>

HTML5+CSS3价格表翻转切换动画

3、书写css代码。

.pricing-container { width: 90%; max-width: 1170px; margin: 4em auto; }

.pricing-container { margin: 6em auto; }

.pricing-container.full-width { width: 100%; max-width: none; }

.pricing-switcher { text-align: center; }

.pricing-switcher .fieldset { display: inline-block; position: relative; padding: 2px; border-radius: 50em; border: 2px solid #2d3e50; }

.pricing-switcher input[type="radio"] { position: absolute; opacity: 0; }

.pricing-switcher label { position: relative; z-index: 1; display: inline-block; float: left; width: 90px; height: 40px; line-height: 40px; cursor: pointer; font-size: 1.4rem; color: #ffffff; }

.pricing-switcher .switch { position: absolute; top: 2px; left: 2px; height: 40px; width: 90px; background-color: #2d3e50; border-radius: 50em; -webkit-transition: -webkit-transform 0.5s; -moz-transition: -moz-transform 0.5s; transition: transform 0.5s; }

.pricing-switcher input[type="radio"]:checked + label + .switch, .pricing-switcher input[type="radio"]:checked + label:nth-of-type(n) + .switch { -webkit-transform: translateX(90px); -moz-transform: translateX(90px); -ms-transform: translateX(90px); -o-transform: translateX(90px); transform: translateX(90px); }

.no-js .pricing-switcher { display: none; }

.pricing-list { margin: 2em 0 0; }

.pricing-list > li { position: relative; margin-bottom: 1em; }

 @media only screen and (min-width: 768px) {

.pricing-list { margin: 3em 0 0; }

.pricing-list:after { content: ""; display: table; clear: both; }

.pricing-list > li { width: 33.3333333333%; float: left; padding-left: 5px; padding-right: 5px; }

.has-margins .pricing-list > li { width: 32.3333333333%; float: left; margin-right: 1.5%; }

.has-margins .pricing-list > li:last-of-type { margin-right: 0; }

}

HTML5+CSS3价格表翻转切换动画

4、书写并添加js代码。

<script src="js/jquery.min.js"></script> 

<script src="js/modernizr.min.js"></script>

<script>

jQuery(document).ready(function($){

checkScrolling($('.pricing-body'));

$(window).on('resize', function(){

window.requestAnimationFrame(function(){checkScrolling($('.pricing-body'))});

});

$('.pricing-body').on('scroll', function(){ 

var selected = $(this);

window.requestAnimationFrame(function(){checkScrolling(selected)});

});

function checkScrolling(tables){

tables.each(function(){

var table= $(this),

totalTableWidth = parseInt(table.children('.pricing-features').width()),

tableViewport = parseInt(table.width());

if( table.scrollLeft() >= totalTableWidth - tableViewport -1 ) {

table.parent('li').addClass('is-ended');

} else {

table.parent('li').removeClass('is-ended');

}

});

}

bouncy_filter($('.pricing-container'));</script>

HTML5+CSS3价格表翻转切换动画

5、代码整体结构。

HTML5+CSS3价格表翻转切换动画

6、查看效果。

HTML5+CSS3价格表翻转切换动画

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢