html table td边框效果

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
 <html>
 <head>
 <title>table边框测试</title>
 </head>css

 <body>
  <div style="width:100%;height:100%;">html


   <table border="1" bordercolor="#FF9966" >
    <tr>
    <td width="102" style="border-right-style:none">隐藏右边框</td>
    <td width="119" style="border-left-style:none">隐藏左边框</td>
    </tr>
    <tr>
    <td style="border-top-style:none">隐藏上边框</td>
    <td style="border-bottom-style:none">隐藏下边框</td>
    </tr>
   </table>ide

 

   <table>
    <tr>
    <td style="border-right:#cccccc solid 1px;">显示右边框</td>
    <td style="border-left:#cccccc solid 1px;">显示左边框</td>
    <td style="border-top:#cccccc solid 1px;">显示上边框</td>
    <td style="border-bottom:#cccccc solid 1px;">显示下边框</td>
    </tr>
   </table>测试

 

   <table>
    <tr>
    <td style="border-right : thin dashed blue;">右边框显示细虚线</td>
    <td style="border-bottom: thick dashed yellow;">下边框显示粗虚线</td>
    <td style="border-top: double green;">上边框显示两条线</td>
    <td style="border-left: dotted red;">左边框显示点</td>
    </tr>
   </table>spa


   
  </div>htm

 </body>
 </html>ip

效果以下:ci

html table td边框效果 - 康陕铭 - KSM的博客-只爱你一个
 
 
 

.表格中边框的显示

只显示上边框 <table frame=above>

只显示下边框 <table frame=below>

只显示左、右边框 <table frame=vsides>

只显示上、下边框 <table frame=hsides>

只显示左边框 <table frame=lhs>

只显示右边框 <table frame=rhs>

不显示任何边框 <table frame=void>get

.表格的分隔线能够隐藏

<table border rules=cols cellspacing=0 align=left> 能够隐藏横向的分隔线

<table border rules=rows cellspacing=0 align=right>能够隐藏纵向的分隔线博客

<table border rules=none cellspacing=0 align=center>能够隐藏横向和纵向的分隔线

-------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<TABLE cellSpacing=0 cellPadding=0 width="90%" align=right border=1 rules=rows frame=hsides style="border-collapse:collapse ; " bordercolor="#000000" >

<TR>
<TD >sadad</TD>
<TD >sad</TD>
<TD>dsa</TD>
<TD>asd</TD>
</TR>
<TR>
<TD >ads</TD>
<TD>asd</TD>
<TD>ads</TD>
<TD>asds</TD>
</TR>

</TABLE>
</BODY>
</HTML>

table width=1 就已经把宽度设置为 1 了
咱们面临的问题是这样的,每个 td 边线都是 1px,table 边线也是 1px。那么当两个td相邻的时候,由于每一个 td 边线都是1,因此靠进的时候边线的“宽度和”就是 1+1=2。当 td 和 table 相邻时,一样。

collapse :  相邻边被合并
相 邻边被合并!之前我说的 1+1=2 就是由于 td 和td之间,td 和table 之间相邻边的问题。默认时相邻边没有合并,因此就是 1+1=2。如今咱们使用 border-collapse:collapse把咱们合并了,因此宽度仍是 1px。也就是出现细线边框了

 

 

设置Table的细边框一般有这么几种方式:

一、设置边框的BORDER=0 、cellspacing=1,设置Table的背景色为所要的边框色,再设置全部的td背景色为白色,这样细边框就显露出来了。这个方法有些邪气,看似不太正宗,可是也能达到效果,条条大路通罗马嘛!

再来看看第二种方法:

二、设置BORDER=0 ,再经过CSS,给Table加上1px的border-top,border-left,而后再设置全部的td的border-right,border-bottom,这样也能达到所要的效果。可见CSS非常强大啊。

今天在实践过程当中发现,以上两种方式生成的HTML在Word中打开则发生问题,不能达到预期效果。怎么办呢!?

下面介绍一种更为简便有效的方法:

三、设置table的CSS为{border-collapse:collapse;border:none;},再设置td的CSS为{border:solid #000 1px;},大功告成!并且Word也能认出这种设置。

第三种方法最好,我也是在导出word时,不少css失效的状况下,找到了这个解决办法!

相关文章
相关标签/搜索