表格不能垂直居中问题解决一例(超简单)
来源:互联网 发布:如何查看淘宝店铺id 编辑:程序博客网 时间:2024/05/20 17:08
近日,公司美工在画一个HTML时,发现表格不能垂直居中,很是困惑,示意源代码为:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="77" align="left" bgcolor=red> </td>
<td align="center" valign="middle" bgcolor=green> </td>
<td width="77" align="left" bgcolor=blue> </td>
</tr>
</table>
</body>
</html>
注意,这里只是示意性的代码,其实美工还写了很多的CSS来试图解决此问题,结果都是于事无补,我分析过那些源代码和CSS文件,并没有什么不妥,甚感怪异,后来笔者对多份能成功居中的HTML一比较,如果加上下面这一行的文档定义,问题就解决了。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">修改后的代码为:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="77" align="left" bgcolor=red> </td>
<td align="center" valign="middle" bgcolor=green> </td>
<td width="77" align="left" bgcolor=blue> </td>
</tr>
</table>
</body>
</html>
OK,就这么简单!
- 表格不能垂直居中问题解决一例(超简单)
- 表格不能垂直居中问题解决一例(超简单)【转】
- 超简单的图片水平垂直居中
- 超简单的图片水平垂直居中
- 纯css实现未知尺寸图片在DIV中垂直水平居中(超简单)
- 表格水平和垂直居中
- CSS垂直居中问题解决方法
- CSS居中之美(一)——垂直居中
- CSS居中(一)--div盒子水平垂直居中
- 超简单的居中
- 让表格垂直居中的问题
- ExtJs 设置GridPanel表格文本垂直居中
- extjs 表格单元格 垂直居中对齐
- css-bootstrap表格如何垂直居中
- Bootstrap表格内容垂直水平居中
- Bootstrap 表格内容水平、垂直居中
- easyui 表格的单元格内容垂直居中
- DokuWiki表格项垂直居中的方法
- 简单易行的办公室保健操
- 不允许dataGridView中的列输入为空
- 漫画版《越狱》人物大全
- 读取xml中的SelectSingleNode方法
- 577w 简体中文版 ROM 定制过程详解
- 表格不能垂直居中问题解决一例(超简单)
- 三句话暴露不职业
- DirectX 3D中某些对象的释放需要手动调用Dispose方法
- psp-2000
- 超级脑力
- 代码阅读方法与实践
- Struts培训A组试题
- Solaris device driver development reference
- Asp.net 默认配置下,Session莫名丢失的原因及解决办法