Bootstrap 3.0附加列表更改宽度

Dav*_*vor 34 css twitter-bootstrap affix twitter-bootstrap-3

我正在迁移到bootstrap 3.0.0并且我在左边有一个附加菜单的问题:一旦它被粘贴(在10px滚动之后),它的宽度就会改变.在这个小提琴中它变得更小,在我的真实网站中它变得更宽,并扩展了实际内容.

它与bootstrap v2.3.2完美配合.检查后看起来列表项目与.affix {position: fixed;}出现的不匹配.

有任何想法吗?

解决方案:基于最新的评论,我最后添加了这个JS片,它可以很好地修复它,而不必为固定元素设置固定宽度:

$(function() {
    var $affixElement = $('div[data-spy="affix"]');
    $affixElement.width($affixElement.parent().width());
});
Run Code Online (Sandbox Code Playgroud)

小智 11

我遇到了同样的问题并修复了这个:

 $(window).resize(function () {
                $('#category-nav.affix').width($('#content').width());
            });
Run Code Online (Sandbox Code Playgroud)

基本上在调整大小的情况下,我计算内容div的宽度并将附加元素的宽度设置为.


小智 8

$(window).scroll(function () {
    $('#secondary .widget-area.affix').width($('#secondary').width());
});
Run Code Online (Sandbox Code Playgroud)