图片/图形

CSS3商品视图模式切换效果

阿里云


所有的商城网站上的产品列表都有两种视图模式:缩略图模式和列表模式。这款 css3 和 js 商城网站商品视图模式切换效果就是模拟这种视图切换效果。这是一款仿商城产品列表的模式切换的插件,使用了 css3 和 javascript 技术制作。

HTML 部分

  1. <div id="cbp-vm" class="cbp-vm-switcher cbp-vm-view-grid">
  2.     <div class="cbp-vm-options">
  3.         <a href="#" class="cbp-vm-icon cbp-vm-grid cbp-vm-selected" data-view="cbp-vm-view-grid">Grid View</a>
  4.         <a href="#" class="cbp-vm-icon cbp-vm-list" data-view="cbp-vm-view-list">List View</a>
  5.     </div>
  6.     <ul>
  7.         <li>
  8.             <a class="cbp-vm-image" href="#"><img src="images/1.png"></a>
  9.             <h3 class="cbp-vm-title">Silver beet</h3>
  10.             <div class="cbp-vm-price">$19.90</div>
  11.             <div class="cbp-vm-details">
  12.                 Silver beet shallot wakame tomatillo salsify mung bean beetroot groundnut.
  13.             </div>
  14.             <a class="cbp-vm-icon cbp-vm-add" href="#">Add to cart</a>
  15.         </li>
  16.         <li>
  17.             <!--  ... -->
  18.         </li>
  19.         <!--  ... -->
  20.     </ul>
  21. </div>
也想出现在这里?联系我们
创客主机

javascript 部分

  1. (function() {
  2.     var container = document.getElementById( 'cbp-vm' ),
  3.         optionSwitch = Array.prototype.slice.call( container.querySelectorAll( 'div.cbp-vm-options > a' ) );
  4.     function init() {
  5.         optionSwitch.forEach( function( el, i ) {
  6.             el.addEventListener( 'click', function( ev ) {
  7.                 ev.preventDefault();
  8.                 _switch( this );
  9.             }, false );
  10.         } );
  11.     }
  12.     function _switch( opt ) {
  13.         // remove other view classes and any any selected option
  14.         optionSwitch.forEach(function(el) { 
  15.             classie.remove( container, el.getAttribute( 'data-view' ) );
  16.             classie.remove( el, 'cbp-vm-selected' );
  17.         });
  18.         // add the view class for this option
  19.         classie.add( container, opt.getAttribute( 'data-view' ) );
  20.         // this option stays selected
  21.         classie.add( opt, 'cbp-vm-selected' );
  22.     }
  23.     init();
  24. })();

CSS3 商品视图模式切换效果

已有 395 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!