友根 發表於 2023-9-22 00:00:00

免插件在wordpress中插入表格的方法

<p>
<span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>WordPress 很强大,但是其编辑器却很简陋,可能 WordPress 依仗着自己有丰富的插件功能所以将后台的编辑器简化了吧。当然,一些简单的文字与图片输入对于 WordPress 编辑器来说是完全能够胜任的,但是如果要输入像表格这类稍稍复杂些的格式就要向 WordPress 投降了。虽然 WordPress 编辑器中有一项“从 Word 粘贴”的功能键,但是从 Word 中复制出来的表格粘贴在 WordPress 中就荡然无存了,就算是在 Dreamweaver 中编辑好的表格代码粘贴到 WordPress 编辑器的 HTML 格式下还是不能完美呈现。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>要在 WordPress 中插入表格,其实并非难事,只要用 wp-table 插件就能轻松做到,但是如果我们一碰到问题就用插件解决,那 WordPress 迟早会被拖垮的。再次重申一下我的口号:能用代码搞定的就绝不用插件解决!所以本文对 wp-table 插件不作任何评价,有需要的朋友可以试试,本文的重点是介绍免插件在 WordPress 中插入表格的方法。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>切入正题,和 用 caption 属性给图片加描述边框一样,要在 WordPress 中插入表格,我们只需要给表格定义一个 CSS 样式就行。参考代码如下: </span></p>
<div style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<p style="margin: 0px; padding: 0px; outline: none; float: right; line-height: 25.2px; font-size: 14px;">
<span style="line-height: 25.2px; cursor: pointer;"><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
/*----------table----------*/ <br>
table.table { <br>
border-spacing:2px; <br>
border-collapse:separate; <br>
background-color:#FFF; <br>
border-color:gray; <br>
border-style:outset; <br>
border-width:1px; <br>
} <br>
table.table th { <br>
background-color:#FFF; <br>
-moz-border-radius:0; <br>
border-color:gray; <br>
border-style:inset; <br>
border-width:1px; <br>
padding:1px; <br>
} <br>
table.table td { <br>
-moz-border-radius:0; <br>
border-color:gray; <br>
border-style:inset; <br>
border-width:1px; <br>
padding:1px; <br>
} </p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在 WordPress 后台编辑器中插入表格时,只需用 Dreamweaver 之类的编辑器事先划好表格,再将代码粘贴至 HTML 格式下,并引用,例如: </span></p>
<div style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<p style="margin: 0px; padding: 0px; outline: none; float: right; line-height: 25.2px; font-size: 14px;">
<span style="line-height: 25.2px; cursor: pointer;"><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
&lt;table border="1" width="200" align="center"&gt; <br>
&lt;tbody&gt; <br>
&lt;tr&gt; <br>
&lt;td&gt;第1行第1列&lt;/td&gt; <br>
&lt;td&gt;第1行第2列&lt;/td&gt; <br>
&lt;/tr&gt; <br>
&lt;tr&gt; <br>
&lt;td&gt;第2行第1列&lt;/td&gt; <br>
&lt;td&gt;第2行第2列&lt;/td&gt; <br>
&lt;/tr&gt; <br>
&lt;/tbody&gt; <br>
&lt;/table&gt; </p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>效果: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>第1行第1列 第1行第2列 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>第2行第1列 第2行第2列</span></p>
頁: [1]
查看完整版本: 免插件在wordpress中插入表格的方法