简体   繁体   English

在html / php中减少表高度

[英]Reducing table height in html/php

I am working plotting one html/php table using following code. 我正在使用以下代码绘制一个html / php表。

$color=array("#000000","#0000FF","00FFFF","#00FF00","#FFFF00","#7FFFD4","#FF0000","#FF9900","#FFFFFF","#00BFFF");
echo "<br>Color Codes:<br><br>";
echo '<table border="1" cellpadding="0" cellspacing="0"><tr>';

     for($i=0;$i< sizeof($color); $i++)
     {
        echo "<td height='5px' width='10' bgcolor='".$color[$i]."'>($i/10)</td>";
     }
 echo  '</tr>';
 echo  '</table><br>'; 

But when I plot this I get following output: 但是当我绘制这个时,我得到以下输出:

在此输入图像描述

Here height does not decrease with height paramer as I need to just create rectangular boxes. 这里高度不会随着高度的变化而降低,因为我需要创建矩形框。

I replicated your code and didn't see what you're seeing, so I think you may have other styles on the page where you're plotting this that are interfering with the layout. 我复制了你的代码并没有看到你所看到的内容,所以我认为你可能在页面上有其他样式,你正在绘制这些样式会干扰布局。 You can take the height attribute off the td elements; 你可以从td元素中取出height属性; then try adding a style="" attribute on the table and testing different properties. 然后尝试在table上添加style=""属性并测试不同的属性。

<table style="line-height: 1;"> - try that for starters. <table style="line-height: 1;"> - 为初学者尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM