2017-08-16 11 views
1

ボタンをクリックしたときにテーブルが点滅するアラームを作成しようとしています。私はそれに適用されたCSSがない行を作ることができる:http://imgur.com/hWxlMAYしかし、それに適用されたCSSの行は色を変えていないようです。ここDojoツールキット - 関数を使用してCSSをオーバーライドするにはどうすればよいですか?

は私のhtmlファイルである:ここ

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8"> 

     <!--load my css--> 
     <link rel="stylesheet" type="text/css" href="alarm.css" /> 
     <!-- load Dojo --> 
     <script>dojoConfig = {parseOnLoad: true}</script> 
     <script src="dojo/dojo.js" data-dojo-config="async: true"></script> 
     <!--load my js file--> 
     <script> require(['myModule.js']); </script> 

     <title>alarm test</title> 
    </head> 

    <body> 
     <h1 id="greeting">Alarm</h1> 
     <!--create table--> 
     <table data-dojo-type="dojox.grid.DataGrid" id="tableContainer"> 
      <thead> 
       <tr> 
        <!--Table headers--> 
        <th field="col1">Company</th> 
        <th field="col2">Contact</th> 
        <th field="col3">Country</th> 
       </tr> 
       <tr> 
        <td>Alfreds Futterkiste</td> 
        <td>Maria Anders</td> 
        <td>Germany</td> 
       </tr> 
       <tr> 
        <td>Centro comercial Moctezuma</td> 
        <td>Francisco Chang</td> 
        <td>Mexico</td> 
       </tr> 
      </thead> 
     </table> 

     <button id="alarm" type="button">Alarm</button> 
     <button id="stopAlarm" type="button">Stop Alarm</button> 
    </body> 
</html> 

私のボタンのクリックイベントハンドラのjsのコードです:

require(["dojo/dom-style", "dojo/dom", "dojo/on", "dojo/dom-class", "dojo/domReady!"], 
function(style, dom, on, domClass){ 
    on(dom.byId("alarm"), "click", function(){ 
      domClass.add(dom.byId("tableContainer"), "blink") 
    }); 
    on(dom.byId("stopAlarm"), "click", function(){ 
      domClass.remove(dom.byId("tableContainer"), "blink") 
     }); 
}); 

、ここでは私のCSSファイルです:

table, th, td { 
    border: 1px solid black; 
} 

table { 
    font-family: arial, sans-serif; 
    border-collapse: collapse; 
    width: 100%; 
} 

td, th { 
    border: 1px solid #dddddd; 
    text-align: left; 
    padding: 8px; 
} 

tr:nth-child(even) { 
    background-color: #dddddd; 
} 

.blink { 
    animation:blink 300ms infinite alternate; 
} 


@keyframes blink { 
    from { background-color: white; } 
    to { background-color: red; } 
}; 

答えて

0

これがされcssの問題であり、dojoの問題ではありません。 blink cssクラスを宣言するときは、より具体的にする必要があります。それ以外の場合は、tr要素に定義されているスタイルが優先されます。次のようなCSS定義を使用できます。

.blink tr { 
    animation:blink 300ms infinite alternate; 
} 
関連する問題