使用相等宽度的表格单元填充整个表空间

时间:2012-06-20 01:15:06

标签: html css html-table equals cells

标题非常自我解释,但基本上我需要表格行等于提供的表格空间,并且表格单元格具有相等的宽度。我在网上尝试了很多建议,但我无法弄清楚。非常感谢任何帮助。

HTML:

<div id="content">
<div id="boxes">
    <table>
        <tr>
            <td>
                <h2>News</h2>

                <h6>The new website is up!</h6>
                <p>The new website is up take a look around and be sure to visit our games page and have a good time. =)</p>
            </td>
            <td>
                <h2>Other Stuff</h2>

                <h6>This is where some other info goes</h6>
                <p>We can type other types of information in here for the general public to know.</p>
            </td>
            <td>test</td>
            <td>test</td>
        </tr>
    </table>
</div><!--end boxes-->
</div><!--end content-->

CSS:

#content{
text-align:center;
width:90%;
margin-left:auto;
margin-right:auto;  
}
#content #boxes table{
table-layout:fixed; 
}
#content #boxes table tr td{
border-top:30px solid #000;
border-left:1px solid #000;
border-right:1px solid #000;
height:250px;
width:23%;
table-layout:fixed;
text-align:left;
float:left;
display:inline-block;   
}
#content #boxes table tr td:hover{
border-top:30px solid #F00;
border-left:1px solid #F00;
border-right:1px solid #F00;    
}

1 个答案:

答案 0 :(得分:1)

#content #boxes table tr td更改为:

border-top:30px solid #000;
border-left:1px solid #000;
border-right:1px solid #000;
border-collapse:collapse;
height:250px;
width:25%;
text-align:left;

Fiddle

编辑:感谢Pumbaa,删除了不必要的指令