Bootstrap 3附加

时间:2013-04-28 12:45:04

标签: javascript css twitter-bootstrap twitter-bootstrap-3

我一直在玩preview of Bootstrap 3,并且遇到了“affix pluggin”的麻烦,它允许使用固定位置的浮动条。

请找一个显示我的麻烦的小提琴here。基本上,右侧按钮确实浮动,但是当应用position: fixed时,从网格系统继承的宽度和偏移样式似乎消失了。

这是我的代码:

<div class='container'>
    <div class='row'>
        <div class='col-span-8'>
            <legend>Lorem</legend>
            <div>[Large amounts of text]</div>
        </div>
        <div class='col-span-4 well' data-spy='affix' data-offset-top='50'>
            <div class='btn btn-large btn-danger col-span-12'>This is fixed</div>
        </div>
    </div>
</div>

我做错了什么? (我知道Bootstrap 3仍在积极开发中,但我希望有人在这里有一些见解。)

1 个答案:

答案 0 :(得分:2)

data-offset-top='50'添加了课程affix-top。该类在bootstrap.css中没有定义。滚动页面后,课程affix会替换课程affix-topaffix定义了固定的位置。这会导致你所加贴的div的不同显示。

也许更改下面显示的代码可以更好地工作。 NB在这种情况下,固定的div不会显示在小屏幕上?!

<div class='container'>
    <div class='row'>
        <div class='col-span-8'>
            <legend>Lorem</legend>
            <div>[Large amounts of text]</div>
        </div>
        <div class='col-span-4'>
            <div class="well col-span-4" data-spy='affix'>
            <div class='btn btn-large btn-danger col-span-12'>This is fixed</div>
            </div>
        </div>
    </div>
</div>