Bootstrap 3.0 affix with list changes width

前端 未结 9 1668
一向
一向 2021-02-01 14:56

I\'m migrating to bootstrap 3.0.0 and I\'m having issues with an affixed menu to the left: as soon as it becomes affixed (after 10px scroll), its width changes. In this fiddle i

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 15:30

    Here's my version.

    var fixAffixWidth = function() {
      $('[data-spy="affix"]').each(function() {
        $(this).width( $(this).parent().width() );
      });
    }
    fixAffixWidth();
    $(window).resize(fixAffixWidth);
    

    CSS

    div.affix {
        position: fixed !important;
    }
    

提交回复
热议问题