How to make fixed position row in bootstrap?

2020-03-24 03:26发布

问题:

I have a table-like structure, where the first <div class="row">... behave as the header for the table.
I am trying to make it fixed, so when I scroll down the page, users can still see the columns headings.
I gave it position:fixed, which achieves that, but now, the width of the columns is trashed.

<div class="container">
            <div class="row" style="position:fixed;">
                <div class="col-md-1">id</div>
                <div class="col-md-3">L Name</div>
                <div class="col-md-1">M</div>
                <div class="col-md-2">F Name</div>
                <div class="col-md-3">Username</div>
                <div class="col-md-2">Phone</div>
            </div><!-- row -->
<!-- some data -->
            <div class="row">
                <div class="col-md-1">id</div>
                <div class="col-md-3">L Name</div>
                <div class="col-md-1">M</div>
                <div class="col-md-2">F Name</div>
                <div class="col-md-3">Username</div>
                <div class="col-md-2">Phone</div>
            </div><!-- row -->
</div>

I really needs this to work on Chrome/FF/Safary. IE is not a concerns

回答1:

Try it <div class="container" style="position: fixed"> EDIT: I create simple example at http://jsfiddle.net/ytJV7/2/