Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom css with kaminari with bootstrap

I try to use paginate with kaminari. My project used bootsrap css, and the result is so ugly:) enter image description here

The html is generated by nokogiri

<nav class="pagination">
    <span class="first">
  <a href="/admin/book_borrow/borrow?locale=en">« First</a>
</span>

    <span class="prev">
  <a rel="prev" href="/admin/book_borrow/borrow?locale=en">‹ Prev</a>
</span>

        <span class="page">
  <a rel="prev" href="/admin/book_borrow/borrow?locale=en">1</a>
</span>

        <span class="page current">
  2
</span>

        <span class="page">
  <a rel="next" href="/admin/book_borrow/borrow?locale=en&amp;page=3">3</a>
</span>

        <span class="page">
  <a href="/admin/book_borrow/borrow?locale=en&amp;page=4">4</a>
</span>

    <span class="next">
  <a rel="next" href="/admin/book_borrow/borrow?locale=en&amp;page=3">Next ›</a>
</span>

    <span class="last">
  <a href="/admin/book_borrow/borrow?locale=en&amp;page=4">Last »</a>
</span>

  </nav>

I want something like pagination in bootstrap page, how I can do? Please help!

like image 364
duykhoa Avatar asked Nov 10 '12 09:11

duykhoa


3 Answers

After I posted this question I found the solution: kaminari: A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for Rails 3.

Just go to the console and type:

rails generate kaminari:views bootstrap4

It will download some Haml files to your application, and the views are changed. It also supports bootstrap 2 and 3 e.g

rails generate kaminari:views bootstrap3

Here are some themes for Kaminari views: https://github.com/amatsuda/kaminari_themes

like image 131
duykhoa Avatar answered Nov 17 '22 08:11

duykhoa


simply add following css to your application.css

.pagination a, .pagination span.current, .pagination span.gap {
    float: left;
    padding: 0 14px;
    line-height: 38px;
    text-decoration: none;
    background-color: white;
    border: 1px solid #DDD;
    border-left-width: 0;
}

.pagination {
    border-left: 1px solid #ddd;
    .first{
        padding : 0;
        float: none;
        border: none;
    }
    .prev {
        padding : 0;
        float: none;
        border: none;
    }
    .page{
        padding : 0;
        float: none;
        border: none;
    }
    .next{
        padding : 0;
        float: none;
        border: none;
    }
    .last{
        padding : 0;
        float: none;
        border: none;
    }
}
like image 25
Rohit Siddha Avatar answered Nov 17 '22 08:11

Rohit Siddha


rails generate kaminari:views bootstrap4

Available themes: bootstrap2, bootstrap3, bootstrap4, bourbon, bulma, foundation, foundation5, github, google, materialize, purecss, semantic_ui

like image 7
Jeremy Lynch Avatar answered Nov 17 '22 08:11

Jeremy Lynch