我正在使用通过 php 编码的表通过 xml 提要形成两列结果,列形式正常,问题是第二列被截断。
我的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/