我用 PHP 生成了 2 个 HTML 表。第一个表始终位于第二个表之上。我似乎无法让他们肩并肩。第二个总是在第一个表下方。
我还尝试在表格的 html 中添加左浮动和内联的 html 样式,但它仍然没有并排出现。任何帮助将不胜感激!
//add table for bids and asks
function build_table($bidarray){
// start table
$html = '<table style="display: inline-block;">';
// header row
$html .= '<tr>';
foreach($bidarray[0] as $key=>$value){
$html .= '<th>' . htmlspecialchars($key) . '</th>';
}
$html .= '</tr>';
// data rows
foreach( $bidarray as $key=>$value){
$html .= '<tr>';
foreach($value as $key2=>$value2){
$html .= '<td>' . htmlspecialchars($value2) . '</td>';
}
$html .= '</tr>';
}
// finish table and return it
$html .= '</table>';
return $html;
}
$bidarray = array(
array('Company'=>'cardsltd', 'Min Qty'=>'5', 'Max Qty'=>'10', '$/box'=>'5.00'),
);
$askarray = array(
array('Company'=>'comp', 'Min Qty'=>'4', 'Max Qty'=>'9', '$/box'=>'4.00'),
);
echo build_table($bidarray) . build_table($askarray) ;
Run Code Online (Sandbox Code Playgroud)
您需要使用<div>s。
采取一个<div>
将两个<div>s 放入其中,每个包含一个表。
<div>
<div style="float:left; width: 49%">
<table>
...
</table>
</div>
<div style="float:left; width: 49%">
<table>
...
</table>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这将使您的桌子并排放置。
此外,我们可以更改/调整/管理宽度。
49%仅用于演示目的。
| 归档时间: |
|
| 查看次数: |
720 次 |
| 最近记录: |