【问题标题】:CSS height element ignoredCSS 高度元素被忽略
【发布时间】:2012-11-06 03:35:07
【问题描述】:

我有两个 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>

CSS:

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

}

边框等已正确添加,因此它可以看到 CSS。当我打开萤火虫时,虽然我在检查其中一张桌子上的 html 时得到以下信息。它承认 element.style 覆盖了高度。

我该如何解决这个问题?

谢谢

【问题讨论】:

  • 只有!important 规则比style 属性强。
  • 啊,完美解决了,谢谢。如果您想要分数,请将其作为答案提交,我会接受。

标签: html css datagrid dojo


【解决方案1】:

style 属性只能通过使用 !important 来覆盖。

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

你应该不惜一切代价避免!important,但是,因为!important只能被!important覆盖(困扰你的整个样式表),内联样式只能覆盖!important样式,如果它们本身就是@ 987654328@ 和 !important 内联样式根本无法被 CSS 覆盖。如果您可以避免创建需要首先覆盖的样式属性,那么您绝对应该这样做。

【讨论】:

  • 应该提到!important的使用表示CSS不好。
  • @AdamWaite 我不是暗示不应该使用样式属性吗?如果您知道更好地表述它的好方法,您可以适当地编辑我的答案。
  • @AdamWaite 现在好点了吗?
猜你喜欢
  • 1970-01-01
  • 2017-02-24
  • 2012-03-25
  • 1970-01-01
  • 2015-12-20
  • 2021-11-10
  • 2011-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多