将可折叠面板的方向更改为向上

时间:2015-01-16 07:25:18

标签: jquery html css

我想将可折叠面板方向更改为。

请将链接视为:

http://dev.genuusdemo.com/demo/

JavaScript:

<script type="text/javascript">
    jQuery(document).ready(function($){
        $(".accordion_example2").smk_Accordion({
            closeAble: true, //boolean
        });     
    });
</script>

2 个答案:

答案 0 :(得分:1)

只需将其固定在底部而不是顶部,它将向上打开......

#accordion{
  width:400px;
  position:absolute;
  bottom:0;
 }
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Accordion - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#accordion" ).accordion({collapsible: true});
  });
  </script>
</head>
<body>
 
<div id="accordion">
  <h3>Section 1</h3>
  <div>
    <p>
    Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
    ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
    amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
    odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
    </p>
  </div>
  <h3>Section 2</h3>
  <div>
    <p>
    Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
    purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
    velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
    suscipit faucibus urna.
    </p>
  </div>
  <h3>Section 3</h3>
  <div>
    <p>
    Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
    Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
    ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
    lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
    </p>
    <ul>
      <li>List item one</li>
      <li>List item two</li>
      <li>List item three</li>
    </ul>
  </div>
  <h3>Section 4</h3>
  <div>
    <p>
    Cras dictum. Pellentesque habitant morbi tristique senectus et netus
    et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
    faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
    mauris vel est.
    </p>
    <p>
    Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
    Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
    inceptos himenaeos.
    </p>
  </div>
</div>
 
 
</body>
</html>

答案 1 :(得分:0)

this.clickHead = function(){

    plugin.on('click', '.acc_head', function(){

        var s_parent = $(this).parent();

        if( s_parent.hasClass('acc_active') == false ){
            if( settings.closeOther ){
                plugin.find('.acc_content').slideUp(settings.slideSpeed);
                plugin.find('.accordion_in').removeClass('acc_active');
            }   
        }

        if( s_parent.hasClass('acc_active') ){
            if( false !== settings.closeAble ){
                s_parent.children('.acc_content').slideUp(settings.slideSpeed);
                s_parent.removeClass('acc_active');
            }
        }
        else{
            // changed the next to prev
            $(this).prev('.acc_content').slideDown(settings.slideSpeed);
            s_parent.addClass('acc_active');
        }

    });

我稍微修改了smk-accordian.js和HTML

    <div class="accordion_in active">
        <div class="acc_content">
fg<!-- Your text here. For this demo, the content is generated automatically.-->
    </div>
    <div class="acc_head">
        <div class="acc_icon_expand"></div>Section 1
    </div>
    </div>