简体   繁体   English

Bootstrap手风琴-折叠时更改顶部面板的位置

[英]Bootstrap Accordion - change the position of top panel when collapse

I'm using bootstrap accordion plugin and my question is: 我正在使用bootstrap手风琴插件,我的问题是:

How can we change the position of the top panel when opened and return to its first position when closed. 打开时如何改变顶板的位置,关闭时如何改变顶板的第一位置。 Please look at the photo: 请看照片:

是的,对于响应迅速的网站;)

Here is the pen , 这是

and thanks in advance, 并预先感谢,

I would do something like this using jQuery: 我会用jQuery做这样的事情:

var original = $('#accordion').position().top;

$('.accordion-toggle').click(function(){
  var parent = $(this).data('parent');
  var body = $(this).attr('href');

  if($(body).is(":visible")) {
    $(parent).animate({top: original}, 350);
  }
  else {
    $(body).css({
        position: 'absolute',
        visibility: 'hidden',
        display: 'block',
        height: 'auto'
    });
  var offset = original - ($(body).height() / 2);
  $(body).removeAttr('style');
    $(parent).animate({top: offset}, 350); 
  } 
});

Hope is helps or puts you in the right direction. 希望是有帮助的或使您朝正确的方向发展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM