dongshou1991 2019-08-02 12:26
浏览 58

如何在html(bootstrap)表列中添加两个水平滚动

I have added a php library(php-diff) with this I am printing difference of page by history (data comes from mysql in html form).

My problem is I want to add two scrolls in footer of table .

I want two scroll i given in attached image ![Two scroll in a table columns] http://prntscr.com/ong7iq

i have tried this with ul li but as data is coming in html form so its break output

 public function render()
{
$changes = parent::render();

$html = '';
if(empty($changes)) {
return $html;
    }
$html .= '<div class="table-responsive">';
$html .= '<table class="Differences DifferencesSideBySide">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th colspan="2">Old Version</th>';
$html .= '<th colspan="2">New Version</th>';
$html .= '</tr>';
$html .= '</thead>';
foreach($changes as $i => $blocks) {
        if($i > 0) {
            $html .= '<tbody class="Skipped">';
            $html .= '<th>&hellip;</th><td>&nbsp;</td>';
            $html .= '<th>&hellip;</th><td>&nbsp;</td>';
            $html .= '</tbody>';
        }

foreach($blocks as $change) {
$html .= '<tbody class="Change'.ucfirst($change['tag']).'">';
// Equal changes should be shown on both sides of the diff
if($change['tag'] == 'equal') {
foreach($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '<tr>';
$html .= '<th>'.$fromLine.'</th>';
$html .= '<td class="Left"><div class="scrollable"> 
    <span>'.$line.'</span>&nbsp;</span></div></td>';
$html .= '<th>'.$toLine.'</th>';
$html .= '<td class="Right"><div class="scrollable"> 
    <span>'.$line.'</span>&nbsp;</span></div></td>';
$html .= '</tr>';
                }
            }
// Added lines only on the right side
else if($change['tag'] == 'insert') {
foreach($change['changed']['lines'] as $no => $line) {
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '<tr>';
$html .= '<th>&nbsp;</th>';
$html .= '<td class="Left"><div class="scrollable">&nbsp;</div></td>';
$html .= '<th>'.$toLine.'</th>';
$html .= '<td class="Right">
    <div class="scrollable"><ins>'.$line.'</ins>&nbsp;</div></td>';
$html .= '</tr>';
}
}
// Show deleted lines only on the left side
else if($change['tag'] == 'delete') {
foreach($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= '<tr>';
$html .= '<th>'.$fromLine.'</th>';
$html .= '<td class="Left"><div class="scrollable"> 
    <del>'.$line.'</del>&nbsp;</div></td>';
$html .= '<th>&nbsp;</th>';
$html .= '<td class="Right"><div class="scrollable">&nbsp;</div>/td>';
$html .= '</tr>';
                }
            }
// Show modified lines on both sides
else if($change['tag'] == 'replace') {
if(count($change['base']['lines']) >= count($change['changed'] 
    ['lines'])) {
foreach($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= '<tr>';
$html .= '<th>'.$fromLine.'</th>';
$html .= '<td class="Left"><div class="scrollable"> 
     <span>'.$line.'</span>&nbsp;</div></td>';

    if(!isset($change['changed']['lines'][$no])) {
$toLine = '&nbsp;';
$changedLine = '&nbsp;';
}
else {
$toLine = $change['base']['offset'] + $no + 1;
$changedLine = '<span>'.$change['changed']['lines'][$no].'</span>';
                        }
$html .= '<th>'.$toLine.'</th>';
$html .= '<td class="Right"><div 
    class="scrollable">'.$changedLine.'</div></td>';
$html .= '</tr>';
                    }
                }
else {
foreach($change['changed']['lines'] as $no => $changedLine) {

    if(!isset($change['base']['lines'][$no])) {
$fromLine = '&nbsp;';
$line = '&nbsp;';
}
else {
$fromLine = $change['base']['offset'] + $no + 1;
$line = '<span>'.$change['base']['lines'][$no].'</span>';
                        }
$html .= '<tr>';
$html .= '<th>'.$fromLine.'</th>';
$html .= '<td class="Left"><div class="scrollable"> 
    <span>'.$line.'</span>&nbsp;</div></td>';
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '<th>'.$toLine.'</th>';
$html .= '<td class="Right"><div 
    class="scrollable">'.$changedLine.'</div></td>';
$html .= '</tr>';
                    }
                }
            }
            $html .= '</tbody>';
        }
    }
$html .= '</table>';
$html .= '</div>';
return $html;
}

i want two scroll i given in attached image ![Two scroll in a table columns] http://prntscr.com/ong7iq

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 CARSIM前车变道设置
    • ¥50 三种调度算法报错 有实例
    • ¥15 关于#python#的问题,请各位专家解答!
    • ¥200 询问:python实现大地主题正反算的程序设计,有偿
    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败