2017-09-21 47 views
0

我使用的是动态表(https://puravidaapps.com/table.php2)随着HTML文档,我发现如何对表格的形式从Materializecss.com改变(stripered或镶上...)在该行:Materialise的CSS改变背景颜色

doc.getElementById("myTable").getElementsByTagName('table')[0].className = "bordered"; 

但我不知道如何改变不同的颜色。如果我想改变2线的背景颜色,我需要在哪里写“卡片面板蓝绿色照亮-2”(我有一个包含大量信息的css文件,但我认为它是materialize.css组件)

谢谢!

<!doctype html> 
<head> 
    <meta name="author" <content="puravidaapps.com"> 
    <meta charset="utf-8"> 
    <meta name="viewport" <content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"> 

    <!--Import materialize.css--> 
    <link type="text/css" rel="stylesheet" href="materialize.min.css" media="screen,projection"/> 

    <title>Table Layout</title> 
</head> 

<body> 
    <div id="myTable"></div> 
    <script> 
    // if you have commas inside your text, feel free to use another delimiter, for example | 
    var delimiter = ","; 

    // get the table to display from the window.AppInventor object and split at new line 
    var urlArray = window.AppInventor.getWebViewString().split("\n"); 
    //var urlArray = location.search.slice(1).split("/n"); 

    var doc = document; 
    var fragment = doc.createDocumentFragment(); 
    var thead = doc.createElement("thead"); 
    var tr = doc.createElement("tr"); 

    // split at delimiter 
    var rowArray = urlArray[0].split(delimiter); 

    addRow(thead, "th"); 
    fragment.appendChild(thead); 

    var tbody = doc.createElement("tbody"); 
    for(i=1;iurlArray.length;i++){ 
     var tr = doc.createElement("tr"); 

     // split at delimiter 
     var rowArray = urlArray[i].split(delimiter); 

     tr.addEventListener ("click", function() { 
     // return index (add 1 because first row is the header row) 
     //window.document.title = this.rowIndex + 1; 
     window.AppInventor.setWebViewString(this.rowIndex + 1); 
     }); 

     addRow(tbody, "td"); 
    } 
    fragment.appendChild(tbody); 
    var table = doc.createElement("table"); 
    table.appendChild(fragment); 
    doc.getElementById("myTable").appendChild(table); 

    // http://stackoverflow.com/a/9236195/1545993 
    doc.getElementById("myTable").getElementsByTagName('table')[0].className = "bordered"; 


    function addRow(dom, tag) { 
     for(j=0;jrowArray.length;j++){ 
     var el = doc.createElement(tag); 
     el.innerHTML = rowArray[j]; 
     tr.appendChild(el); 
     dom.appendChild(tr); 
     } 
    } 
    </script> 
</body> 
</html> 

回答

0

您需要使用Sass才能更改materialize的预设css值。

在文件[_variables.scss][1]中,如果您想更深入地进行自定义(添加自定义颜色等),您可以修改不同类型的参数,检查组件文件夹,您将得到您想要的。

.scss是不是由您的浏览器可读,你需要安装青菜和使用此命令行编译成.css

sass --watch scss/materialize.scss:compiled/test.css

从风格文件夹中假设以下路径:

  • app
    • style
      • SCSS
      • 编译

sass watch explained