将单元格内容适合HTML CSS表格中的单元格高度

时间:2015-03-21 10:45:44

标签: css html5

我使用以下代码生成了一个css样式表。我试图用内容(这里是DATA1和DATA2)来适应单元格高度。但我无法生成内容适合高度的单元格。我怎么能这样做?

我试着用here提到的东西,但它没有表现出蚂蚁的变化。请注意,我保持宽度为100%,我只关注高度适合。

<style>
#customers 
{
font-family: Arial, Helvetica, sans-serif;
width: 100%;
border-collapse: collapse;
}


#customers td, #customers th 
{    
border: 1px solid #98bf21;
padding: 3px 7px 2px 7px;
font-size:15px
}


#customers tr.alt td
{
color: #000000;
background-color: #EAF2D3;
}
</style>
</head>
<body>

<table id="customers"> 
<tr class="alt">
<td>DATA1 </td>
<td>DATA2</td>    
</tr>
</table>

1 个答案:

答案 0 :(得分:0)

    <style>
#customers 
{
font-family: Arial, Helvetica, sans-serif;

border-collapse: collapse;
}


#customers td, #customers th 
{    
border: 1px solid #98bf21;
line-height:10px;
font-size:15px
}


#customers tr.alt td
{
color: #000000;
background-color: #EAF2D3;
}
</style>
</head>
<body>

<table id="customers"> 
<tr class="alt">
<td>DATA1 </td>
<td>DATA2</td>    
</tr>
</table>

从#customer td和#th中删除填充,它会对单元格和内容之间的顶部和底部间隙进行排序,并使用行高:Xpx使单元格触及内容(甚至覆盖内容)

相关问题