手风琴

响应式带滚动条手风琴插件

阿里云

这是一款响应式的带滚动条的 jQuery 和 css3 内容手风琴插件。该手风琴插件的每个手风琴项都可以带滚动条,并且它的内容会随屏幕的大小做自适应的调整,效果非常不错。

HTML 结构:

html 结构使用 section.aw-accordion 来作为 wrapper。在里面放置多个 div 作为手风琴项。

也想出现在这里?联系我们
创客主机
  1. <section class="aw-accordion">
  2.     <div class="one">
  3.         <h1>Sport</h1>
  4.         <span><img src="img/sports.jpg">......</span>
  5.     </div>
  6.     。。。
  7. </section>

CSS 样式:

该手风琴插件的 css 样式如下:

  1. body{
  2.   background:#34495e;
  3.   font-family:'Open Sans', sans-serif;
  4. }
  5.  
  6. section.aw-accordion{
  7.   width:800px; 
  8.   margin:40px auto;
  9.   margin-bottom:30px;
  10. }
  11.  
  12. section.aw-accordion .one, 
  13. section.aw-accordion .two, 
  14. section.aw-accordion .three, 
  15. section.aw-accordion .four{
  16.   font-size:14px;
  17.   width:23%;
  18.   float:left;
  19.   height:230px;
  20.   display:inline-block;
  21.   z-index:1;
  22.   position:relative;
  23.   overflow:hidden;
  24.   padding:1%;
  25.   transition:all 200ms cubic-bezier(0.645, 0.575, 0.090, 1.000);
  26.   cursor: default;
  27. }
  28.  
  29. section.aw-accordion .one span, 
  30. section.aw-accordion .two span, 
  31. section.aw-accordion .three span, 
  32. section.aw-accordion .four span{
  33.    background: -webkit-linear-gradient(left, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  34.     -webkit-background-clip: text;
  35.     -webkit-text-fill-color: transparent;
  36.   height:100%;
  37.   display:table;
  38. }
  39.  
  40. section.aw-accordion .one{
  41.   background-color:#3498db;
  42.   border-radius:10px 0 0 10px;
  43. }
  44.  
  45. section.aw-accordion .two{
  46.   background-color:#e74c3c;
  47. }
  48.  
  49. section.aw-accordion .three{
  50.   background-color:#1abc9c;
  51. }
  52.  
  53. section.aw-accordion .four{
  54.   background-color:#f1c40f;
  55.   border-radius:0 10px 10px 0;
  56. }
  57.  
  58. section.aw-accordion .one:hover, 
  59. section.aw-accordion .two:hover, 
  60. section.aw-accordion .three:hover, 
  61. section.aw-accordion .four:hover{
  62.   overflow-y: auto;
  63. }
  64.  
  65. section.aw-accordion .one:hover span,
  66. section.aw-accordion .two:hover span,
  67. section.aw-accordion .three:hover span,
  68. section.aw-accordion .four:hover span{
  69.    background: -webkit-linear-gradient(left, rgba(255, 255, 255, .7), rgba(255, 255, 255, .7));
  70.     -webkit-background-clip: text;
  71.     -webkit-text-fill-color: transparent;
  72. }
  73.  
  74. section.aw-accordion div::-webkit-scrollbar {  
  75.     width: 12px;  
  76. }  
  77. section.aw-accordion div::-webkit-scrollbar-track {  
  78.     background-color: rgba(1, 1, 1, .1);
  79. }  
  80. section.aw-accordion div::-webkit-scrollbar-thumb {  
  81.     background-color: rgba(1, 1, 1, .2);
  82. }  
  83. section.aw-accordion div::-webkit-scrollbar-thumb:hover {  
  84.     background-color: rgba(1, 1, 1, .3);
  85. }  
  86.  
  87. section.aw-accordion div img{
  88.   float:left; 
  89.   margin:0 10px 0 0;
  90.   border:3px solid rgba(255, 255, 255, .2);
  91.   box-shadow:0 0 15px rgba(1, 1, 1, .1);
  92.   -webkit-box-shadow:0 0 15px rgba(1, 1, 1, .1);
  93.   -moz-box-shadow:0 0 15px rgba(1, 1, 1, .1);
  94.   width:150px;
  95. }
  96.  
  97. section.aw-accordion div img,
  98. section.aw-accordion div h1{
  99.   opacity:.3; 
  100.   transition:all .3s
  101. }
  102.  
  103. section.aw-accordion div:hover img,
  104. section.aw-accordion div:hover h1{
  105.   opacity:1;
  106. }
  107.  
  108. section.aw-accordion div h1{
  109.   margin:0 0 5px;
  110.   font-weight:300; 
  111.   color:white;
  112. }
  113. @media (max-width:1024px){
  114.   section.aw-accordion .one,
  115.   section.aw-accordion .two,
  116.   section.aw-accordion .three,
  117.   section.aw-accordion .four{
  118.     font-size:12px;
  119.   }
  120.  
  121.   section.aw-accordion div img{
  122.     width:80px;
  123.   }
  124.  
  125.   section.aw-accordion div h1{
  126.     font-size:120%
  127.   }
  128. }
  129.  
  130. @media (max-width:768px){
  131.   section.aw-accordion div img{
  132.     width:60px;
  133.   }
  134.  
  135.   section.aw-accordion div h1{
  136.     font-size:100%
  137.   }
  138. }
  139.  
  140. /* Styling Demo */
  141. section.aw-accordion > h1{
  142.   color:#233445;
  143.   display:block;
  144.   width:100%;
  145. }
  146.  
  147. section.aw-accordion > h1 > .read-article{
  148.   color:#233445;
  149.   border-radius:5px;
  150.   border:1px solid #233445;
  151.   padding:4px 8px;
  152.   text-decoration:none;
  153.   float:right;
  154.   text-align:center;
  155.   font-size:80%;
  156. }
  157.  
  158. section.aw-accordion > h1 > .read-article:hover{
  159.   color:white;
  160.   border:1px solid white;
  161. }
  162.  
  163. @media (max-width:768px){
  164.   section.aw-accordion{
  165.     width:100%; 
  166.   }
  167.   section.aw-accordion h1{
  168.     font-size:80%;
  169.     letter-spacing:-1px;
  170.   }
  171. }

JAVASCRIPT 代码:

引入 jQuery 文件:

  1. <script src='http://libs.useso.com/js/jquery/1.11.0/jquery.min.js'></script>

使用 jQuery 的 mouseover 事件来完成手风琴效果:

  1. <script>
  2. $('section.aw-accordion div').mouseover(function () {
  3.     $(this).css('width', '50%');
  4.     $(this).siblings('div').css('width', '14%');
  5. });
  6. </script>

响应式带滚动条手风琴插件

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

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

发表回复

热销模板

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

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