如何将ui主题用于jquery数据表?

akr*_*abi 6 jquery user-interface datatables themeroller jquery-ui-theme

我一直在尝试将"平滑"主题添加到我的jquery数据表中但没有成功.我的数据表只是没有样式.

这是我的标题代码:

<style type="text/css" title="currentStyle">
    @import "/DataTables/media/css/smoothness/jquery-ui-1.8.21.custom.css"
</style>
<script type="text/javascript" language="javascript" src="DataTables/media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="DataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" src="DataTables/media/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $('#join').dataTable( {
                "bJQueryUI": true,
                "sPaginationType": "full_numbers"
            } );
    } );    
</script>
Run Code Online (Sandbox Code Playgroud)

以下是身体的形式:

<table id="join" cellpadding="0" cellspacing="0" border="0" class="display" width="80%">
<thead>
    <tr>
        <th>Column 1</th>
        <th>Column 2</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>Row 1 Data 1</td>
        <td>Row 1 Data 2</td>
    </tr>
    <tr>
        <td>Row 2 Data 1</td>
        <td>Row 2 Data 2</td>
    </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

我到底错在了什么?

谢谢你的帮助.

ᾠῗᵲ*_*ᵲᄐᶌ 7

您需要导入jquery.dataTables_themeroller.css文件,以便它可以使用主题.或者,如果您不使用主题,那么只需使用jquery.dataTables.css

你也应该尝试像这样导入你的CSS

<link rel="stylesheet" href="DataTables/media/css/smoothness/jquery-ui-1.8.21.custom.css"/>
<link rel="stylesheet" href="DataTables/media/css/jquery.dataTables_themeroller.css"/>
Run Code Online (Sandbox Code Playgroud)

或者如果你想保留import语句 - 你错过了那个url部分

<style type="text/css" title="currentStyle">
   @import url("DataTables/media/css/smoothness/jquery-ui-1.8.21.custom.css");
   @import url("DataTables/media/css/jquery.dataTables_themeroller.css");
</style>
Run Code Online (Sandbox Code Playgroud)

所以最后你的css没有被导入,因此你的表没有应用格式