【问题标题】:CSS for cell padding用于单元格填充的 CSS
【发布时间】:2018-05-30 14:42:44
【问题描述】:

我想使所有行的大小相同,但数据的行高很大。我想为空行修复此行大小。表类名称为 demo。 Demo

<?php
   while($fet=mysql_fetch_assoc($sql1))
  {
  $id=$fet['c_id'];
  $address=$fet['address'];
   $chk=$fet["c_name"];
    $in=$in+1;
    echo "<tr>";
    echo "<td style='align:center'><a class='astext' href='client_view.php?cid=".$fet["c_id"]."'>".$fet["c_name"]."</a></td>";  
    echo "<td style='align:center'><a class='ima' href='client_details.php?cid=".$fet["c_id"]."'><img src='image/edit1.png' alt='edit' style='width:20px; height:20px' title=Edit></a></td><td style='align:center'>
    <a class='ima' href='clients.php?del=".$fet["c_id"]."'><img src='image/delete1.png' alt='delete' style='width:20px;height:20px' title=Delete></a></td>";
           echo "</tr>";
      }
   if ($in < 10) {
   $empty_rows = 10 - mysql_num_rows($sql1);

    for ($m = 0; $m < $empty_rows; $m++) {
    echo '<tr><td></td><td></td><td></td></tr>';
    }
   }
?>

【问题讨论】:

    标签: php css mysql html-table


    【解决方案1】:

    您需要在代码中添加以下CSS

    .demo td{        
        height:20px;
    }
    

    Demo

    【讨论】:

    • 请不要重复回答。
    【解决方案2】:

    为tr添加固定高度

    table tr {
    height: 40px;
    box-sizing: border-box;
    }
    

    检查小提琴:http://jsfiddle.net/4gqgzdL8/1/

    如果你需要 box-sizing,你可以使用它,否则不要使用

    【讨论】:

      【解决方案3】:

      尝试像这样为 td 设置高度和行高:Demo

      .demo td {
       line-height:28px;
       height:28px;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-05-08
        • 2015-06-04
        • 2011-03-15
        • 2017-12-14
        • 1970-01-01
        • 2010-09-25
        • 1970-01-01
        相关资源
        最近更新 更多