html表格单元格间距设不了是为什么

html-css06

html表格单元格间距设不了是为什么,第1张

操作失败。html软件的内部公告信息显示,表格里面的单元格间距是需要选择设置单元格选项进行设置,出现设不了的情况是因为操作失败,只需要选择单元格设置进行就可以了。表格,又称为表,既是一种可视化交流模式。

1、CSS法

可以在标签中设置margin属性,即:style="margin:5px

0

5px

0"(顺序:上、右、下左,亦可简写为style="margin:

5px

0"),这段CSS的作用是在当前表格外部的上下各留出5px的空白。

2、空对象法

1)空行。还可以在表格后敲回车换行,产生<p></p>标签,或者按Shift+回车软换行,产生</br>标签,都可产生一个空行。

(2)空表格。插入一个1行1列的表格,设置单元格的宽度、高度,在单元格中不输入内容。当单元格高度小于12px时,一定要将空格符

删掉,否则达不到设定高度,这一点非常重要。即:

<table

width="100%

"

border="0"

csllapacing="0"

csllapacing="0"

>

<tr>

<td

height="5"></td>

</tr>

</table>

(3)空DIV。类似于空表格,插入一个DIV,设置其宽度、高度,超出隐藏即可。

3、透明图片法<可以在PS中新建一个5x5px的画布,背景设为透明,保存为透明GIF图片,然后在需要留间距的表格后面插入这个透明图片,将其宽度、高度可以任意调整,直到满意为直。

 1、利用 height属性,这样是直接拉高 td 单元格的高度,缺点:文字不能对齐

2、做为height属性文字垂直不对齐的补充,增加 line-height属性,与height相同时则垂直居中,但换行则会导致两行间距太大。

3、padding-top padding-bottom 可以增加上下边距,很好用的属性,在bootstrap框架中是通过这个属性实现表格样式的。就算多行,也是一样保持间距。

或者结合使用,选择一款适合的。

.table tr td { padding:10px 0} 这样设置省事。

实现代码:

<table cellspacing="0" style="color:#FFFtext-align:leftfont-size:14pxfont-weight:boldmargin-left:220pxwidth:980pxheight:200pxtext-align:center">

<tr >

<td bgcolor="e91e6f"style=" width:196px">01</td>

<td bgcolor="224071"style=" width:196px">02</td>

<td bgcolor="f12339"style=" width:196px">03 </td>

<td bgcolor="1ea27e"style=" width:196px">04</td>

<td bgcolor="224071"style=" width:196px">05</td>

</tr>

<tr>

<td bgcolor="1ea27e">06</td>

<td bgcolor="e91e6f">07</td>

<td bgcolor="224071">08</td>

<td bgcolor="f12339">09 </td>

<td bgcolor="1ea27e">10</td>

</tr>

<tr>

<td bgcolor="e91e6f">11</td>

<td bgcolor="224071">12</td>

<td bgcolor="f12339">13</td>

<td bgcolor="1ea27e">14 </td>

<td bgcolor="224071">15</td>

</tr>

<tr>

<td bgcolor="1ea27e">16</td>

<td bgcolor="e91e6f">17</td>

<td bgcolor="224071">18</td>

<td bgcolor="f12339"></td>

<td bgcolor="1ea27e"></td>

</tr>

</table>