上下两个表格之间为什么中间会有大约5象素的间距?

本文介绍了一种解决HTML页面中上下表格间出现多余间距的方法。通过设置图片的宽高属性并调整代码格式,成功消除了5像素的间距,确保了网页布局的准确性。

今天发现一个问题:上下两个表格中间有大约5象素的间距。
代码是这样的

<!--head-->
    <div align="center">
        <table width="778" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <img src="images/head.gif"></td>
            </tr>
        </table>
    </div>
    <!--end head-->
    <!--menu-->
    <div align="center">
        <table width="778" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <img src="images/menu_1.gif" width="8" height="37" alt=""></td>
                <td>
                    <img src="images/menu_2.gif" width="668" height="37" alt=""></td>
                <td>
                    <img src="images/menu_3.gif" width="13" height="37" alt=""></td>
                <td>
                    <img src="images/menu_4.gif" width="67" height="37" alt=""></td>
                <td>
                    <img src="images/menu_5.gif" width="22" height="37" alt=""></td>
            </tr>
        </table>
    </div>
    <!--end menu-->

最后经过调试,终于发现是因为head中image的宽度和高度没有设定。改成下面的代码即可。

<!--head-->
    <div align="center">
        <table width="778" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <img src="images/head.gif" width="778" height="98" alt=""></td>
            </tr>
        </table>
    </div>
    <!--end head-->
    <!--menu-->
    <div align="center">
        <table width="778" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <img src="images/menu_1.gif" width="8" height="37" alt=""></td>
                <td>
                    <img src="images/menu_2.gif" width="668" height="37" alt=""></td>
                <td>
                    <img src="images/menu_3.gif" width="13" height="37" alt=""></td>
                <td>
                    <img src="images/menu_4.gif" width="67" height="37" alt=""></td>
                <td>
                    <img src="images/menu_5.gif" width="22" height="37" alt=""></td>
            </tr>
        </table>
    </div>
    <!--end menu-->

如果还有间隔的话,把<td><img src="" width="" height=""></td> 中间不要留空格。

转载于:https://www.cnblogs.com/ami/archive/2006/07/20/455768.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值