- 论坛徽章:
- 1
|
〖转帖〗教你用HTML代码做帖(教程总汇)
一:背景(表格)
--------------------------------------------------------------------------------
1:背景(论坛中帖子的外背景)
- <body background="背景图片URL地址">;
复制代码
body的相关属性:
- <body background="URL地址" bgcolor=# text=# link=# alink=# vlink=#>;
复制代码
background=背景图片URL地址(设定了背景图片后bgcolor设定值将无效)
bgcolor --- 背景色彩
text --- 非可链接文字的色彩
link --- 可链接文字的色彩
alink --- 正被点击的可链接文字的色彩
vlink --- 已经点击(访问)过的可链接文字的色彩
#=rrggbb
色彩是用 16 进制的 红-绿-蓝(red-green-blue, RGB) 值来表示。
16 进制的数码有: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.
--------------------------------------------------------------------------------
2:表格
效果如:(见我的blog,>;_<)
- <TABLE align=center background="帖子背景图" border=0 cellPadding=0 cellSpacing=0 borderColor=#ffff00 width="100%">;<TBODY>;<TR>;<TD>;
- 帖子内容,文字或图片..... </TD>;</TR>;</TBODY>;</TABLE>;
复制代码
<TABLE>; 的参数设定(常用):
- <table width="400" border="1" cellspacing="2" cellpadding="2" align="CENTER" valign="TOP" background="myweb.gif" bgcolor="#0000FF" bordercolor="#CF0000" bordercolorlight="#00FF00" bordercolordark="#00FFFF" cols="2">;
复制代码
注解:
width="400"
表格宽度,接受绝对值(如 80)及相对值(如 80%)。
border="1"
表格边框的厚度,不同浏览器有不同的内定值,故请指明。
cellspacing="2"
表格格线的厚度
align="CENTER"
表格的摆放位置(水平),可选值为: left, right, center
valign="TOP".
表格内内容的对齐方式(垂直),可选值为: top, middle, bottom。
background="myweb.gif"
表格的背景图片,与 bgcolor 不要同用。
bgcolor="#0000FF"
表格的底色,与 background 不要同用
bordercolor="#CF0000"
表格边框颜色
bordercolorlight="#00FF00"
表格边框向光部分的颜色
bordercolordark="#00FFFF"
表格边框背光部分的颜色,使用 bordercolorlight 或 bordercolordark 时 bordercolor 将会失效。
cols="2"
表格栏位数目,只是让浏览器在下载表格时先画出整个表格而已。
--------------------------------------------------------------------------------
附:利用表格属性做漂亮的代码边框。
一些新手看到别人做出漂亮的帖子边框都很好奇是怎么做成的,说穿了也就是巧妙的应用了表格的相关属性。这里我就统计几种常见的表格使用方法,可能大家也有更多更好的想法,也就起个抛砖引玉的作用吧。
例1:
说明:看起来好像是用了四层表格,其实只用了两层,同一个背景图。主要是边框向光和背光部分的颜色应用起到的效果。
- <table align="center" border="1" cellpadding="8" cellspacing="10" width="500" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj01.jpg" bordercolorlight="#0C091D" bordercolordark="#C0B4FE">;<tr>;<td width="100%" align="center">;<table align="center" border="1" cellpadding="4" cellspacing="6" width="100%" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj01.jpg" bordercolorlight="#0C091D" bordercolordark="#C0B4FE">;<tr>;<td width="100%" align="center">;
- <br>;<br>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/jchanxing.jpg">;
- <br>;<br>;</td>;</tr>;</table>;</td>;</tr>;</table>;
复制代码
--------------------------------------------------------------------------------
例2:
说明:这种效果其实有好几种方法做出来,但是在我认为这种是最简单的,只是金色背景那层(第二层)表格的宽是100%其它属性值一律为0。主要是在第三层,第三层的宽width的取值要是99%,而第三层的td里的width属性要是100%。
- <table align="center" border="0" cellpadding="0" cellspacing="10" width="500" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj01.jpg">;<tr>;<td width="100%" align="center">;<table lign="center" border="0" cellpadding="0" cellspacing="0" width="100%" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj02.jpg">;<tr>;<td width="100%" align="center">;<table align="center" border="0" cellpadding="0" cellspacing="0" width="99%" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj01.jpg">;<tr>;<td width="100%" align="center">;
- <br>;<br>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/jchanxing.jpg">;
- <br>;<br>;</td>;</tr>;</table>;</td>;</tr>;</table>;</td>;</tr>;</table>;
复制代码
--------------------------------------------------------------------------------
例3:(效果见我的blog,>;_<)
说明:这个好像没什么特别的,就是把四个角上的框架图用表格分开。
- <br>;<table align="center" border="0" cellpadding="0" cellspacing="0" width="500" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj01.jpg">;<tr>;<td width="100%" align="center">;<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>;<TBODY>;<TR>;<TD width="50%" align=left>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/ta1.gif">;</TD>;<TD width="50%" align=right>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/ta2.gif">;</TD>;</TR>;</TBODY>;</TABLE>;
- <br>;<br>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/jchanxing.jpg">;
- <br>;<br>;
- <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>;<TBODY>;<TR>;<TD width="50%" align=left>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/ta3.gif">;</TD>;<TD width="50%" align=right>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/ta4.gif">;</TD>;</TR>;</TBODY>;</TABLE>;</td>;</tr>;</table>;
复制代码
--------------------------------------------------------------------------------
例4:(效果见我的blog,>;_<)
说明:把图片应用到边框上面,整个表格的大小很重要,调整也是件麻烦的事,所以建议大家用表格格线的厚度cellspacing的属性值或者是表格格线的间距cellpadding的属性值来调整。
- <table align="center" border="1" cellpadding="0" cellspacing="10" width="400" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj03.jpg" bordercolorlight="#C0B4FE" bordercolordark="#0C091D">;<tr>;<td width="100%" align="center">;<table align="center" border="1" cellpadding="0" cellspacing="18" width="100%" background="http://cry.shidabbs.com/home/bbsjc/images/xing.gif" bordercolor="#C0B4FE">;<tr>;<td width="100%" align="center">;<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj01.jpg">;<tr>;<td width="100%" align="center">;
- <br>;<br>;<img border="0" src="http://cry.shidabbs.com/home/bbsjc/images/jchanxing.jpg">;
- <br>;<br>;</td>;</tr>;</table>;</td>;</tr>;</table>;</td>;</tr>;</table>;
复制代码
--------------------------------------------------------------------------------
关与内容居中:
说明:
一般大家做帖子为了美观总是把整体内容全都居中,内容中的文字图片等都加上了居中的代码CENTER,频繁的使用同一组代码,用多了大家是不是觉得有些杂乱的感觉?在这里我都教大家一招,只需要用一次就可以使整个表格内的内容全都居中。
下面是大家一般使用的表格代码:
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj03.jpg">;<tr>;<td>;</td>;</tr>;</table>;
将其改成如下代码:
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" background="http://cry.shidabbs.com/home/bbsjc/images/jcbj03.jpg">;<tr>;<td width="100%" align="center">;</td>;</tr>;</table>;
这样样在表格内的文字图片等都不用再加居中代码了,直接插入就可以了。 |
|