php - Css 和 php 布局问题

标签 php css

我正在使用通过 php 编码的表通过 xml 提要形成两列结果,列形式正常,问题是第二列被截断。

此处示例:http://www.qrrw.net/b

我的CSS

td.manu {
    background: url("../images/manu_button.fw.png") no-repeat; 
    height: 87px; 
    width:478;  
    font-family:Arial,Helvetica, sans-serif; 
    color:#309;
    font-size:12px;
}

当我使用 chrome web 开发人员插件时,它显示第二列的宽度不同,但它使用的是相同的类。

下面是我的 PHP 代码:

$count = 0;
$max = 2;
foreach($xml->name as $name){               
    $count++;
    echo '<td class="manu">'. $name['name'];'</td>';

    if($count >= $max){
        //reset counter
        $count = 0;
        //end and restart
        echo '</tr><tr>';
    }
}
?>

最终的 HTML

  <table border=0 width="800px">
  <tr>
  <td class="manu">3000 ME</td><td class="manu">Ace</td></tr><tr><td class="manu">Cobra MK IV</td>    </tr></table>

谢谢

最佳答案

你的 css 有误。
检查下面 css 中的注释行..

width:478; 更改为 width:478px;

td.manu {
  background: url("../images/manu_button.fw.png") no-repeat; 
  height: 87px; 
  width:478;  /*------------------- add "px" after the value here--------------*/  
  /*----- 478px instead of only 478 ------*/
  font-family:Arial,Helvetica, sans-serif; 
  color:#309;
  font-size:12px;
}

关于php - Css 和 php 布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13305512/

相关文章:

php - PHP 中相当于 Ruby 的 `__END__` 或 Perl 的 `__DATA__` 的构造

css - 如何使用 CSS 以像素为单位缩放元素?

html - 当显示设置为内联时,margin-top 不起作用

php - 如何在 PHP 中将垂直表格与水平 View 对齐

javascript - PHP 变量未在 Javascript 中回显

php - 如果等于从数据库检索的值,则选中该复选框

PHP 代码风格修正器 : put space between colon and method's return type

javascript - 如何从渐变映射数字特定颜色

html - ie6 和 ie7 删除图像 Sprite 周围的边框

jquery - 动画宽度。为什么它不起作用?