Material Design Lite - 資料表



MDL 提供了一系列 CSS 類,可應用各種預定義的視覺化和行為增強,並將表格顯示為資料表。下表列出了可用類及其效果。

序號 類名和描述
1

mdl-data-table

將表格標識為 MDL 元件,並且在表格元素中必需。

2

mdl-js-data-table

為表格設定基本的 MDL 行為,並且在表格元素中必需。

3

mdl-data-table--selectable

設定全部/各個可選行為(複選框),並且是可選的;在表格元素中。

4

mdl-data-table__cell--non-numeric

為資料單元格設定文字格式,並且是可選的;出現在表格標題和表格資料單元格中。

5

(無)

預設情況下,將數字格式設定為標題或資料單元格。

範例

以下示例將幫助您瞭解使用 mdl-data-table 類顯示資料表的用法。

mdl_data_tables.htm

<html>
   <head>
      <script 
         src = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js">
      </script>
      <link rel = "stylesheet" 
         href = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css">
      <link rel = "stylesheet" 
         href = "https://fonts.googleapis.com/icon?family=Material+Icons">	  
   </head>
   
   <body>
      <table class = "mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp">
         <thead>
            <tr><th class = "mdl-data-table__cell--non-numeric">Student</th>
               <th>Class</th><th>Grade</th></tr>
         </thead>
         
         <tbody>
            <tr><td class = "mdl-data-table__cell--non-numeric">Mahesh Parashar</td>
               <td>VI</td><td>A</td></tr>
            <tr><td class = "mdl-data-table__cell--non-numeric">Rahul Sharma</td>
               <td>VI</td><td>B</td></tr>
            <tr><td class = "mdl-data-table__cell--non-numeric">Mohan Sood</td>
               <td>VI</td><td>A</td></tr>
         </tbody>
      </table>
   
   </body>
</html>

結果

驗證結果。

廣告