Ruby gems Will_Paginate 样式

Cod*_*ude 3 ruby pagination ruby-on-rails ruby-on-rails-6

将 Will_paginate gem 用于 ruby​​ on rails 应用程序,但我没有使用 Bootstrap。我该如何设计页面按钮的样式?我在这里不知所措。想也许 will_paginate @posts 吗?或者什么 oo 和样式,我在谈论 CSS 以防万一。

wid*_*ayd 6

你可以使用这个 css(没有引导程序)

.digg_pagination {
  background: white;
  cursor: default;
  /* self-clearing method: */ }
  .digg_pagination a, .digg_pagination span, .digg_pagination em {
    padding: 0.2em 0.5em;
    display: block;
    float: left;
    margin-right: 1px; }
  .digg_pagination .disabled {
    color: #999999;
    border: 1px solid #dddddd; }
  .digg_pagination .current {
    font-style: normal;
    font-weight: bold;
    background: #2e6ab1;
    color: white;
    border: 1px solid #2e6ab1; }
  .digg_pagination a {
    text-decoration: none;
    color: #105cb6;
    border: 1px solid #9aafe5; }
    .digg_pagination a:hover, .digg_pagination a:focus {
      color: #000033;
      border-color: #000033; }
  .digg_pagination .page_info {
    background: #2e6ab1;
    color: white;
    padding: 0.4em 0.6em;
    width: 22em;
    margin-bottom: 0.3em;
    text-align: center; }
    .digg_pagination .page_info b {
      color: #000033;
      background: #6aa6ed;
      padding: 0.1em 0.25em; }
  .digg_pagination:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden; }
  * html .digg_pagination {
    height: 1%; }
  *:first-child + html .digg_pagination {
    overflow: hidden; 
}
Run Code Online (Sandbox Code Playgroud)

并在您的 erb 中添加 css 类,如下面的示例

<% if @news.any? %>
  <%= render @news %>
  <div class="digg_pagination">
    <%= will_paginate %>
  </div>
<% end %>
Run Code Online (Sandbox Code Playgroud)


Ysh*_*rov 5

这是最简单的解决方案https://github.com/delef/will_paginate-bootstrap4

添加到您的 Gemfile:

gem 'will_paginate-bootstrap4'
Run Code Online (Sandbox Code Playgroud)

用法

<%= will_paginate @clients, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %>
Run Code Online (Sandbox Code Playgroud)

给你

在此输入图像描述