数据表样式不起作用 [英] Datatable styling not working

查看:63
本文介绍了数据表样式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特殊的问题。我正在开发一个需要Datatables才能使用的php网站。我注意到在localhost上运行Firefox或Chrome时,Datatables样式不起作用。我的代码如下:

I have a peculiar problem. I am developing a php site that required Datatables to work with it. I noticed that Datatables styling does not work when I run it on localhost be it Firefox or Chrome. My code is as follows:

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link rel="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"/>
        <script src="//code.jquery.com/jquery-2.2.3.js" type="text/javascript"></script>
        <script src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js" type="text/javascript"></script>
        <script>
        $(document).ready(function() {
            $('#example').DataTable();
        } );
        </script>
    </head>
    <body>
        <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
        <tbody>
            <tr>
                <td>Tiger Nixon</td>
                <td>System Architect</td>
                <td>Edinburgh</td>
                <td>61</td>
                <td>2011/04/25</td>
                <td>$320,800</td>
            </tr>
            <tr>
                <td>Garrett Winters</td>
                <td>Accountant</td>
                <td>Tokyo</td>
                <td>63</td>
                <td>2011/07/25</td>
                <td>$170,750</td>
            </tr>
            <tr>
                <td>Ashton Cox</td>
                <td>Junior Technical Author</td>
                <td>San Francisco</td>
                <td>66</td>
                <td>2009/01/12</td>
                <td>$86,000</td>
            </tr>
                    </tbody>
    </table>
    </body>
</html>

这给了我一个相当丑陋的数据表版本。搜索功能和过滤有效,但是缺少样式和列重新排序。

And this gives me a rather ugly version of the datatable. Search functionalities and filtering works but is missing styles and column reordering.

但是,奇怪的是,我绘制的jsfiddle包含了与预期相同的数据,所有样式等...小提琴链接如下: https://jsfiddle.net/gkyya29h/

However the strange thing is that a jsfiddle that I drew up containing the same data render as expected, with all styling, etc... The fiddle link is as follows: https://jsfiddle.net/gkyya29h/

我使用XAMPP服务器,将Firefox作为默认浏览器。有人可以帮我解决这个问题吗?我可能犯了一些非常明显的错误,但看不到它。谢谢。

I'm using XAMPP server with firefox as my default browser. Can someone help me figure this out? I may be doing some very obvious mistake but I'm failing to see it. Thank You.

推荐答案

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">

您指向CSS的链接标记是错误的。也许某些浏览器无法正确处理它。

Your link tag to CSS is wrong. Maybe some browsers won't process it correctly.

这篇关于数据表样式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆