表格的宽度因display:block而冻结 [英] Table's width frozen because of display: block

查看:468
本文介绍了表格的宽度因display:block而冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个包含和其中的一些数据的页面。虽然我将table的宽度设置为它的父div的80%,但内部的 tbody 和其他孩子的宽度被冻结为450px。



我还注意到,一旦我删除了属性 display:block ,表格的子项就被正确显示了(表格的100%宽度)

我有宽度冻结在450px的特殊原因吗?我检查了CSS中的任何地方,并且没有设置这样的规则。



以下是我的表格的代码:

 < div id =maincol> 
< tbody>
< tr>
...


解决方案

显示类型: table (并且它是唯一可能的),同样 tr td 分别显示 table-row 表格单元格


I created a page containing a table and some data in it. Although I set table's width to 80% of it's parent div, the inner tbody and other children's width is frozen to 450px.

I also noticed that once I removed the property display: block, the table's children were correctly displayed (100% width of the table)

I there a particular reason for width to be frozen at 450px ? I checked everywhere in my CSS, and I did not set such a rule.

Here is the code of my table :

<div id="maincol">
<table width="80%" border="0" cellpadding="1" cellspacing="0" id="dates" class="summary" name="dates" style="display:block">
    <tbody>
        <tr>
                 ...

解决方案

tables have their own display type: "table" (and it's the only one possible), similarly tr and td have respectively display "table-row" and "table-cell"

这篇关于表格的宽度因display:block而冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆