CSS高度元素被忽略

Fue*_*ers 1 html css dojo datagrid

我有两个DataGrid表,我想要200px高,但有些东西覆盖了我的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>
Run Code Online (Sandbox Code Playgroud)

CSS:

.statisticsTable {
width: 800px;
height: 200px;
border-style:solid;
border-width:1px;
border-color:#C1C1C1; 
Run Code Online (Sandbox Code Playgroud)

}

Borders等正在被正确添加,因此它可以看到CSS.当我打开firebug时,虽然在检查其中一个表上的html时得到以下内容.它承认element.style正在压倒高度.

在此输入图像描述

我该如何解决这个问题?

谢谢

Joh*_*rak 12

style属性只能通过使用被重写!important.

.statisticsTable {
  height: 200px !important;
  /* ... */
}
Run Code Online (Sandbox Code Playgroud)

!important但是,您应该不惜一切代价避免,因为!important只能!important用它来覆盖整个样式表,内联样式只能覆盖!important样式(如果它们本身)!important,并且!important内联样式根本不能被CSS覆盖.如果您可以避免首先创建需要覆盖的样式属性,那么您一定要这样做.

  • 应该提到使用`!important`表示CSS很差. (3认同)