Centering the pagination in bootstrap

前端 未结 14 1981
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 13:30

I have this code in pagination


                      
相关标签:
14条回答
  • 2020-12-07 14:18

    bootstrap 4 :

    <!-- Default (left-aligned) -->
    <ul class="pagination" style="margin:20px 0">
      <li class="page-item">...</li>
    </ul>
    
    <!-- Center-aligned -->
    <ul class="pagination justify-content-center" style="margin:20px 0">
      <li class="page-item">...</li>
    </ul>
    
    <!-- Right-aligned -->
    <ul class="pagination justify-content-end" style="margin:20px 0">
      <li class="page-item">...</li>
    </ul> 
    
    0 讨论(0)
  • 2020-12-07 14:20

    solution for Bootstrap 4

    You can use it Alignment use this class justify-content-center

    Change the alignment of pagination components with flexbox utilities.

    and learn more about it pagination

    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
    
    
    
    <nav aria-label="Page navigation example">
      <ul class="pagination justify-content-center">
        <li class="page-item disabled">
          <a class="page-link" href="#" tabindex="-1">Previous</a>
        </li>
        <li class="page-item"><a class="page-link" href="#">1</a></li>
        <li class="page-item"><a class="page-link" href="#">2</a></li>
        <li class="page-item"><a class="page-link" href="#">3</a></li>
        <li class="page-item">
          <a class="page-link" href="#">Next</a>
        </li>
      </ul>
    </nav>

    0 讨论(0)
  • 2020-12-07 14:22

    For both Bootstrap 3.0 and 2.3.2, to center pagination, the .text-center class can be applied to the containing div.

    Note: Where to apply the .pagination class in the markup has changed between Bootstrap 2.3.2 and 3.0. See below, or read the Bootstrap docs on pagination: Bootstrap 3.0, Bootstrap 2.3.2.

    Bootstrap 3 Example

    <div class="text-center">
        <ul class="pagination">
            <li><a href="?p=0" data-original-title="" title="">1</a></li> 
            <li><a href="?p=1" data-original-title="" title="">2</a></li> 
        </ul>
    </div>
    

    http://jsfiddle.net/mynameiswilson/eYNMu/

    Bootstrap 2.3.2 Example

    <div class="pagination text-center">
        <ul>
            <li><a href="?p=0" data-original-title="" title="">1</a></li> 
            <li><a href="?p=1" data-original-title="" title="">2</a></li> 
        </ul>
    </div>
    

    http://jsfiddle.net/mynameiswilson/84X3M/

    0 讨论(0)
  • 2020-12-07 14:23
    You can use the below code to center pagination 
    

    .pagination-centered {
        text-align: center;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="pagination-centered">
        <ul class="pagination">
          <li class="active"><a href="#">1</a></li>
          <li><a href="#">2</a></li>
          <li><a href="#">3</a></li>
        </ul>
    </div>

    0 讨论(0)
  • 2020-12-07 14:24

    It works for me:

    <div class="text-center">
    <ul class="pagination pagination-lg">
       <li>
      <a href="#" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    <li><a href="#">1</a></li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">4</a></li>
    <li><a href="#">5</a></li>
    <li>
      <a href="#" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
    </ul>
    

    0 讨论(0)
  • 2020-12-07 14:29

    This css works for me:

    .dataTables_paginate {
       float: none !important;
       text-align: center !important;
    }
    
    0 讨论(0)
提交回复
热议问题