Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: адаптивный аккордион

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Без описания
imediasun2
Отправлено: 16 Февраля, 2013 - 12:48:42
Post Id


Гость


Покинул форум
Сообщений всего: 107
Дата рег-ции: Сент. 2012  


Помог: 0 раз(а)




Почему может открываться только блоки слева?
[url]http://exportgrain.org/plugs/demo_1278/index2.php#[/url]
PHP:
скопировать код в буфер обмена
  1.  
  2. <div class="wrapper" style="background:#fff;margin:20px 20px 20px 20px;float:right">
  3. <div id="st-accordion" class="st-accordion" style="float:right;margin:20px 20px 20px 20px">
  4. <ul><?include_once 'bd.php';
  5. mysql_query("SET NAMES utf8");
  6. $sql="SELECT * FROM categories";
  7. $query=mysql_query($sql)or die (mysql_error());
  8. while($row = mysql_fetch_array($query)){
  9. ?>
  10. <li >
  11. <a href="#"><?echo $row['title'];?><span class="st-arrow">Открыть или закрыть</span></a>
  12. <p>Раскрыть категорию на всю страницу и вывести все компании в категории</p>
  13. <div class="st-content" style="">
  14. <a href="#"><?echo $row['title'];?></a>
  15. </div>
  16. </li><?
  17. }              
  18. ?>     
  19. </ul>  
  20. </div>
  21. </div>
  22. <div class="wrapper" style="background:#fff;margin:20px 20px 20px 20px;float:left">
  23. <div id="st-accordion" class="st-accordion" style="float:right;margin:20px 20px 20px 20px">
  24. <ul><?include_once 'bd.php';
  25. $sql="SELECT * FROM categories";
  26. $query=mysql_query($sql)or die (mysql_error());
  27. while($row = mysql_fetch_array($query)){
  28. ?>
  29. <li >
  30. <a href="#"><?echo $row['title'];?><span class="st-arrow">Открыть или закрыть</span></a>
  31. <p>Раскрыть категорию на всю страницу и вывести все компании в категории</p>
  32. <div class="st-content" style="">
  33. <a href="#"><?echo $row['title'];?></a>
  34. </div>
  35. </li><?
  36. }              
  37. ?>     
  38. </ul>  
  39. </div>
  40.  

css
CODE (html):
скопировать код в буфер обмена
  1.  
  2. .wrapper{
  3.         width:100%;
  4.         max-width:1000px;
  5.  
  6. }
  7.  
  8. .st-accordion{
  9.     width:40%;
  10.     min-width:400px;
  11.        
  12.  
  13. }
  14.  
  15. .st-accordion ul li{
  16.     height: 100px;
  17.     border-bottom: 1px solid #c7deef;
  18.     border-top:1px solid #fff;
  19.     overflow: hidden;
  20. }
  21.  
  22. .st-accordion ul li:first-child{
  23.     border-top:none;
  24. }
  25.  
  26. .st-accordion ul li > a{
  27.     font-family: 'Josefin Slab',Georgia, serif;
  28.     text-shadow: 1px 1px 1px #fff;
  29.     font-size: 20px;
  30.     display: block;
  31.         position: relative;
  32.     line-height: 100px;
  33.         outline:none;
  34.     -webkit-transition:  color 0.2s ease-in-out;
  35.         -moz-transition:  color 0.2s ease-in-out;
  36.         -o-transition:  color 0.2s ease-in-out;
  37.         -ms-transition:  color 0.2s ease-in-out;
  38.         transition:  color 0.2s ease-in-out;
  39. }
  40.  
  41. .st-accordion ul li > a span{
  42.         background: transparent url(../images/down.png) no-repeat center center;
  43.         text-indent:-9000px;
  44.         width: 26px;
  45.         height: 14px;
  46.         position: absolute;
  47.         top: 50%;
  48.         right: -26px;
  49.         margin-top: -7px;
  50.         opacity:0;
  51.         -webkit-transition:  all 0.2s ease-in-out;
  52.         -moz-transition:  all 0.2s ease-in-out;
  53.         -o-transition:  all 0.2s ease-in-out;
  54.         -ms-transition:  all 0.2s ease-in-out;
  55.         transition:  all 0.2s ease-in-out;
  56. }
  57.  
  58. .st-accordion ul li > a:hover{
  59.     color: #1693eb;
  60. }
  61.  
  62. .st-accordion ul li > a:hover span{
  63.         opacity:1;
  64.         right: 10px;
  65. }
  66.  
  67. .st-accordion ul li.st-open > a{
  68.     color: #1693eb;
  69. }
  70.  
  71. .st-accordion ul li.st-open > a span{
  72.         -webkit-transform:rotate(180deg);
  73.         -moz-transform:rotate(180deg);
  74.     transform:rotate(180deg);
  75.         right:10px;
  76.         opacity:1;
  77. }
  78.  
  79. .st-content{
  80.     padding: 5px 0px 30px 0px;
  81. }
  82.  
  83. .st-content p{
  84.     font-size:  16px;
  85.     font-family:  Georgia, serif;
  86.     font-style: italic;
  87.     line-height:  28px;
  88.     padding: 0px 4px 15px 4px;
  89. }
  90.  
  91. .st-content img{
  92.     width:125px;
  93.     border-right:1px solid #fff;
  94.     border-bottom:1px solid #fff;
  95. }
  96.  
  97. @media screen and (max-width: 320px){
  98.         .st-accordion ul li > a{
  99.                 font-size:36px;
  100.         }
  101. }
  102.  
  103.  
  104.  
  105.  

(Отредактировано автором: 16 Февраля, 2013 - 18:35:14)

 
 Top
imya
Отправлено: 16 Февраля, 2013 - 14:41:24
Post Id



Участник


Покинул форум
Сообщений всего: 1472
Дата рег-ции: Сент. 2012  
Откуда: Запорожье, Украина


Помог: 19 раз(а)




А где код js?


-----
PHP:
скопировать код в буфер обмена
  1. do {box != cat;} while (cat != box);


Когда нормальный человек, уезжая из дома одевает на жену пояс верности, веб-дизайнер ставит на нее счетчик...
 
My status
 Top
imediasun2
Отправлено: 16 Февраля, 2013 - 14:48:39
Post Id


Гость


Покинул форум
Сообщений всего: 107
Дата рег-ции: Сент. 2012  


Помог: 0 раз(а)




Но вот все таки и JS
CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. (function( window, $, undefined ) {
  3.        
  4.         /*
  5.         * smartresize: событие измения размера отскоком для jQuery
  6.         *
  7.         * Последняя версия доступна на Github:
  8.         * https://github.com/louisremi/jquery.smartresize.js
  9.         *
  10.         * Copyright 2011 @louis_remi
  11.         * Licensed under the MIT license.
  12.         *
  13.         * Перевод: команда сайта RUSELLER.COM
  14.         */
  15.  
  16.         var $event = $.event, resizeTimeout;
  17.  
  18.         $event.special.smartresize      = {
  19.                 setup: function() {
  20.                         $(this).bind( "resize", $event.special.smartresize.handler );
  21.                 },
  22.                 teardown: function() {
  23.                         $(this).unbind( "resize", $event.special.smartresize.handler );
  24.                 },
  25.                 handler: function( event, execAsap ) {
  26.                         // Сохраняем контекст
  27.                         var context = this,
  28.                                 args    = arguments;
  29.  
  30.                         // Устанавливаем корректный тип события
  31.                         event.type = "smartresize";
  32.  
  33.                         if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
  34.                         resizeTimeout = setTimeout(function() {
  35.                                 jQuery.event.handle.apply( context, args );
  36.                         }, execAsap === "execAsap"? 0 : 100 );
  37.                 }
  38.         };
  39.  
  40.         $.fn.smartresize                        = function( fn ) {
  41.                 return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] );
  42.         };
  43.        
  44.         $.Accordion                             = function( options, element ) {
  45.        
  46.                 this.$el                        = $( element );
  47.                 // Пункты списка
  48.                 this.$items                     = this.$el.children('ul').children('li');
  49.                 // Общее количество пунков
  50.                 this.itemsCount         = this.$items.length;
  51.                
  52.                 // Инициализация аккордеона
  53.                 this._init( options );
  54.                
  55.         };
  56.        
  57.         $.Accordion.defaults            = {
  58.                 // Индекс открытого пункта. -1 означает, что все пункты закрыты по умолчанию.
  59.                 open                    : -1,
  60.                 // Если данная опция имеет значение true, то только один пункт может быть открыт. При открытии пункта другой открытый пункт закрывается.
  61.                 oneOpenedItem   : false,
  62.                 // Скорость анимации открытия/закрытия
  63.                 speed                   : 600,
  64.                 // Эффект анимации открытия/закрытия
  65.                 easing                  : 'easeInOutExpo',
  66.                 // Скорость прокрутки анимации действия
  67.                 scrollSpeed             : 900,
  68.                 // Эффект прокрутки анимации действия
  69.                 scrollEasing    : 'easeInOutExpo'
  70.     };
  71.        
  72.         $.Accordion.prototype           = {
  73.                 _init                           : function( options ) {
  74.                        
  75.                         this.options            = $.extend( true, {}, $.Accordion.defaults, options );
  76.                        
  77.                         // Проверка опций
  78.                         this._validate();
  79.                        
  80.                         // current - индекс открытого пункта
  81.                         this.current            = this.options.open;
  82.                        
  83.                         // Скрываем содержание, чтобы вывести его потом
  84.                         this.$items.find('div.st-content').hide();
  85.                        
  86.                         // Сохраняем оригинальную высоту и координату по вертикали для каждого пункта
  87.                         this._saveDimValues();
  88.                        
  89.                         // Если нужно по умолчанию открыть пункт
  90.                         if( this.current != -1 )
  91.                                 this._toggleItem( this.$items.eq( this.current ) );
  92.                        
  93.                         // Инициализируем события
  94.                         this._initEvents();
  95.                        
  96.                 },
  97.                 _saveDimValues          : function() {
  98.                
  99.                         this.$items.each( function() {
  100.                                
  101.                                 var $item               = $(this);
  102.                                
  103.                                 $item.data({
  104.                                         originalHeight  : $item.find('a:first').height(),
  105.                                         offsetTop               : $item.offset().top
  106.                                 });
  107.                                
  108.                         });
  109.                        
  110.                 },
  111.                 // Проверка опций
  112.                 _validate                       : function() {
  113.                
  114.                         // Индекс открытого пункта должен иметь значение между -1 и общим количеством пунктов, иначе установим его в значение -1
  115.                         if( this.options.open < -1 || this.options.open > this.itemsCount - 1 )
  116.                                 this.options.open = -1;
  117.                
  118.                 },
  119.                 _initEvents                     : function() {
  120.                        
  121.                         var instance    = this;
  122.                        
  123.                         // Открыть / закрыть пункт
  124.                         this.$items.find('a:first').bind('click.accordion', function( event ) {
  125.                                
  126.                                 var $item                       = $(this).parent();
  127.                                
  128.                                 // Закрыть любой открытый пункт если опция oneOpenedItem имеет значнеие true
  129.                                 if( instance.options.oneOpenedItem && instance._isOpened() && instance.current!== $item.index() ) {
  130.                                        
  131.                                         instance._toggleItem( instance.$items.eq( instance.current ) );
  132.                                
  133.                                 }
  134.                                
  135.                                 // Открыть / закрыть пункт
  136.                                 instance._toggleItem( $item );
  137.                                
  138.                                 return false;
  139.                        
  140.                         });
  141.                        
  142.                         $(window).bind('smartresize.accordion', function( event ) {
  143.                                
  144.                                 // Сброс оригинальных занчений пункта
  145.                                 instance._saveDimValues();
  146.                        
  147.                                 // Сброс высоты содержания любого пункта, который открыт
  148.                                 instance.$el.find('li.st-open').each( function() {
  149.                                        
  150.                                         var $this       = $(this);
  151.                                         $this.css( 'height', $this.data( 'originalHeight' ) + $this.find('div.st-content').outerHeight( true ) );
  152.                                
  153.                                 });
  154.                                
  155.                                 // Прокрутка до текущего пункта
  156.                                 if( instance._isOpened() )
  157.                                 instance._scroll();
  158.                                
  159.                         });
  160.                        
  161.                 },
  162.                 // Проверка наличия открытых пунктов
  163.                 _isOpened                       : function() {
  164.                
  165.                         return ( this.$el.find('li.st-open').length > 0 );
  166.                
  167.                 },
  168.                 // Открыть / закрыть пункт
  169.                 _toggleItem                     : function( $item ) {
  170.                        
  171.                         var $content = $item.find('div.st-content');
  172.                        
  173.                         ( $item.hasClass( 'st-open' ) )
  174.                                        
  175.                                 ? ( this.current = -1, $content.stop(true, true).fadeOut( this.options.speed ), $item.removeClass( 'st-open' ).stop().animate({
  176.                                         height  : $item.data( 'originalHeight' )
  177.                                 }, this.options.speed, this.options.easing ) )
  178.                                
  179.                                 : ( this.current = $item.index(), $content.stop(true, true).fadeIn( this.options.speed ), $item.addClass( 'st-open' ).stop().animate({
  180.                                         height  : $item.data( 'originalHeight' ) + $content.outerHeight( true )
  181.                                 }, this.options.speed, this.options.easing ), this._scroll( this ) )
  182.                
  183.                 },
  184.                 // Прокрутка до текущего или последнего открытого пункта
  185.                 _scroll                         : function( instance ) {
  186.                        
  187.                         var instance    = instance || this, current;
  188.                        
  189.                         ( instance.current !== -1 ) ? current = instance.current : current = instance.$el.find('li.st-open:last').index();
  190.                        
  191.                         $('html, body').stop().animate({
  192.                                 scrollTop       : ( instance.options.oneOpenedItem ) ? instance.$items.eq( current ).data( 'offsetTop' ) : instance.$items.eq( current ).offset().top
  193.                         }, instance.options.scrollSpeed, instance.options.scrollEasing );
  194.                
  195.                 }
  196.         };
  197.        
  198.         var logError                            = function( message ) {
  199.                
  200.                 if ( this.console ) {
  201.                        
  202.                         console.error( message );
  203.                        
  204.                 }
  205.                
  206.         };
  207.        
  208.         $.fn.accordion                          = function( options ) {
  209.        
  210.                 if ( typeof options === 'string' ) {
  211.                
  212.                         var args = Array.prototype.slice.call( arguments, 1 );
  213.  
  214.                         this.each(function() {
  215.                        
  216.                                 var instance = $.data( this, 'accordion' );
  217.                                
  218.                                 if ( !instance ) {
  219.                                         logError( "Нельзя вызвать метод до инициализации; " +
  220.                                         "попытка вызвать метод '" + options + "'" );
  221.                                         return;
  222.                                 }
  223.                                
  224.                                 if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
  225.                                         logError( "Нет такого метода в аккордеоне :'" + options );
  226.                                         return;
  227.                                 }
  228.                                
  229.                                 instance[ options ].apply( instance, args );
  230.                        
  231.                         });
  232.                
  233.                 }
  234.                 else {
  235.                
  236.                         this.each(function() {
  237.                                 var instance = $.data( this, 'accordion' );
  238.                                 if ( !instance ) {
  239.                                         $.data( this, 'accordion', new $.Accordion( options, this ) );
  240.                                 }
  241.                         });
  242.                
  243.                 }
  244.                
  245.                 return this;
  246.                
  247.         };
  248.        
  249. })( window, jQuery );
  250.  
  251.  

(Отредактировано автором: 16 Февраля, 2013 - 15:24:41)

 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« Вопросы новичков »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB