2012-11-17 110 views
1

我有兩個DataGrid表格,我想使200px高,但重寫在我的CSS高度。目前這些表格在顯示時有兩種完全不同的尺寸。CSS高度元素被忽略

表:

<table dojoType="dojox.grid.DataGrid" id="dnToCountDiv" data-dojo-id="dnToCountDiv" columnReordering="true" 
          sortFields="['extension','totalcalls','totaloutboundcalls','internaloutboundcalls','localoutboundcalls','longdistanceoutboundcalls','internationaloutboundcalls','totalinboundcalls','inboundinternalcalls','inboundexternalcalls']" 
          rowWidth="100%" 
          noDataMessage="<span class='dojoxGridNoData'>No Calls to Show</span>" 
          class="statisticsTable"> 
         <thead> 
          <tr> 
           <th field="extension" width="100%" >Extension</th> 
           <th field="totalcalls" width="100%" >Total</th> 
           <th field="totaloutboundcalls" width="100%" > Total Out</th> 
           <th field="internaloutboundcalls" width="100%" >Internal Out</th> 
           <th field="localoutboundcalls" width="100%" >Local Out</th> 
           <th field="longdistanceoutboundcalls" width="100%" >Long Dist Out</th> 
           <th field="internationaloutboundcalls" width="100%" >Internat. Out</th> 
           <th field="totalinboundcalls" width="100%" >Total In</th> 
           <th field="inboundinternalcalls" width="100%" >Internal In</th> 
           <th field="inboundexternalcalls" width="100%" >External In</th> 
          </tr> 
         </thead> 
        </table> 

        <!-- dn to call time table --> 
        <h3>Call Time Per Extension 
         <button data-dojo-type="dijit.form.Button" id="call_time_help_button" data-dojo-props="iconClass: 'helpIconClass'">Column Key 
          <script type="dojo/method" data-dojo-event="onClick" > 
           alert("call Time help pressed"); 
          </script> 
         </button></h3> 
        <table dojoType="dojox.grid.DataGrid" id="dnToTimeDiv" data-dojo-id="dnToTimeDiv" columnReordering="true" 
          sortFields="['extension','totalcalls','totaloutboundcalls','internaloutboundcalls','localoutboundcalls','longdistanceoutboundcalls','internationaloutboundcalls','totalinboundcalls','inboundinternalcalls','inboundexternalcalls']" 
          rowWidth="100%" 
          noDataMessage="<span class='dojoxGridNoData'>No Calls to Show</span>" 
          class="statisticsTable"> 
         <thead> 
          <tr> 
           <th field="extension" width="100%" >Extension</th> 
           <th field="totalcalls" width="100%" >Total</th> 
           <th field="totaloutboundcalls" width="100%" > Total Out</th> 
           <th field="internaloutboundcalls" width="100%" >Internal Out</th> 
           <th field="localoutboundcalls" width="100%" >Local Out</th> 
           <th field="longdistanceoutboundcalls" width="100%" >Long Dist Out</th> 
           <th field="internationaloutboundcalls" width="100%" >Internat. Out</th> 
           <th field="totalinboundcalls" width="100%" >Total In</th> 
           <th field="inboundinternalcalls" width="100%" >Internal In</th> 
           <th field="inboundexternalcalls" width="100%" >External In</th> 
          </tr> 
         </thead> 
        </table> 

CSS:

.statisticsTable { 
width: 800px; 
height: 200px; 
border-style:solid; 
border-width:1px; 
border-color:#C1C1C1; 

}

邊界,這樣越來越正確添加,因此看到了CSS。當我打開螢火蟲時,雖然我在檢查其中一個表格上的html時得到以下結果。它承認element.style覆蓋了高度。

enter image description here

我將如何解決這一問題?

由於

+2

只有'!重要'的規則比'style'屬性更強。 –

+0

ahhh完美的修復它謝謝你。如果您想將分數作爲答案提交,我會接受它。 – FuegoFingers

回答

12

style屬性只能通過使用!important被重寫。

.statisticsTable { 
    height: 200px !important; 
    /* ... */ 
} 

你應該避免!important不惜一切代價,但是,由於!important只能通過!important覆蓋(困擾着你與它整個樣式表),內嵌樣式只能覆蓋!important風格,如果他們自己!important!important在線樣式不能被CSS重寫。如果您可以避免創建您首先需要重寫的樣式屬性,那麼您絕對應該這樣做。

+3

應該提到使用'!important'表示CSS不好。 –

+0

@AdamWaite我不是暗示說風格屬性不應該被使用嗎?如果你知道更好的配方,你可以自由地編輯我的答案。 –

+0

@AdamWaite現在好了嗎? –