javascript - Bootstrap 3 affix - Stack Overflow

I have been playing with a preview of Bootstrap 3, and have had troubles with the "affix pluggin&q

I have been playing with a preview of Bootstrap 3, and have had troubles with the "affix pluggin", which allows for fixed-position floating bars.

Please find a fiddle here showing my troubles. Basically, the right-hand side button does float, but the width and offset styling inherited from the grid system seems to disappear when position: fixed is applied.

This is my code:

<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>

What am I doing wrong? (I know Bootstrap 3 is still under active development, but I hope someone with have some insight here.)

I have been playing with a preview of Bootstrap 3, and have had troubles with the "affix pluggin", which allows for fixed-position floating bars.

Please find a fiddle here showing my troubles. Basically, the right-hand side button does float, but the width and offset styling inherited from the grid system seems to disappear when position: fixed is applied.

This is my code:

<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>

What am I doing wrong? (I know Bootstrap 3 is still under active development, but I hope someone with have some insight here.)

Share Improve this question edited Aug 13, 2013 at 8:38 edsioufi 8,3453 gold badges38 silver badges42 bronze badges asked Apr 28, 2013 at 12:45 RandomblueRandomblue 117k150 gold badges363 silver badges558 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

data-offset-top='50' adds the class affix-top. This class has no definition in bootstrap.css. After scrolling the page the class affix replace the class affix-top. affix defines the position fixed. This caused different displays of your affixed div.

Maybe Changing your code to shown below works more as expected. NB in this case The affixed div isn't shown on small screens?!

<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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745400358a4626071.html

相关推荐

  • javascript - Bootstrap 3 affix - Stack Overflow

    I have been playing with a preview of Bootstrap 3, and have had troubles with the "affix pluggin&q

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信