jQuery / DataTables:如何更改分页颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20182500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 01:01:29  来源:igfitidea点击:

jQuery / DataTables: how to change pagination color

jquerycssdatatablespagination

提问by user2571510

I am using the jQuery DataTables plugin (version 1.9.4) and would like to change the color of the pagination.

我正在使用 jQuery DataTables 插件(版本 1.9.4)并想更改分页的颜色。

With CSS I am able to change their background color but I couldnt find a way to change the font color and font hover color for the anchor tags. I would like to change both font color and hover font color for all the below anchor tags to white (#FFFFFF).

使用 CSS,我可以更改它们的背景颜色,但我找不到更改锚标记的字体颜色和字体悬停颜色的方法。我想将以下所有锚标记的字体颜色和悬停字体颜色更改为白色(#FFFFFF)。

The pagination code looks as follows:

分页代码如下所示:

<div id="myTable_paginate" class="dataTables_paginate paging_full_numbers">
    <a id="myTable_first" class="first paginate_button paginate_button_disabled" tabindex="0">First</a>
    <a id="myTable_previous" class="previous paginate_button paginate_button_disabled" tabindex="0">Previous</a>
    <span>
        <a class="paginate_active" tabindex="0">1</a>
        <a class="paginate_button" tabindex="0">2</a>
    </span>
    <a id="myTable_next" class="next paginate_button" tabindex="0">Next</a>
    <a id="myTable_last" class="last paginate_button" tabindex="0">Last</a>
</div>

Thanks for any help with this, Tim.

感谢您对此的任何帮助,蒂姆。

回答by davidkonrad

Maybe you miss the !importantdeclaration? In this case it is indeed important.

也许你错过了!important声明?在这种情况下,它确实很重要。

.paging_full_numbers a.paginate_button {
    color: #fff !important;
}
.paging_full_numbers a.paginate_active {
    color: #fff !important;
}

jsfiddle -> http://jsfiddle.net/CrBkT/

jsfiddle -> http://jsfiddle.net/CrBkT/

回答by Scott M

after a bit of messing about this is what i got to work;

经过一番混乱之后,我开始工作了;

    .page-item.active .page-link {
        color: #fff !important;
        background-color: #000 !important;
        border-color: #000 !important; 
    }

    .page-link {
        color: #000 !important;
        background-color: #fff !important;
        border: 1px solid #dee2e6 !important; 
    }

    .page-link:hover {
        color: #fff !important;
        background-color: #000 !important;
        border-color: #000 !important; 
    }

回答by Mohsen

Another answer is here:

另一个答案在这里

$.fn.dataTable.ext.classes.sPageButton = 'your class';