0

I work on a cakephp app. In my index views, I want to fix the table headers. I saw this question and tried to use it, but did not work in my case.

<?= $this->Paginator->paginator() ?>
    <table class="hoverTable dataTable">
        <thead>
            <tr>
                <th><?= $this->Paginator->sort('id') ?></th>
                <th><?= $this->Paginator->sort('name') ?></th>
                <th><?= $this->Paginator->sort('erial_number') ?></th>
                <th class="actions"><?= __('Actions') ?></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($assets as $asset): ?>
            <tr>
                <td><?= $asset->id ?></td>
                ....
                <td class="actions">
                    <?= $this->Html->iconButton('glyphicon-eye-open', __(''), [
                        'controller' => 'Assets',
                        'action' => 'view', $asset['id']])
                    ?>
                    ....
                </td>       
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

in my CSS, I have:

    .hoverTable{
        border-collapse: collapse;
        margin: 12px 0 0 0;
        width: 100%;
    }        
    .hoverTable th {
        padding: .6em 1em;
        background: #d0f0e9;
        font-weight: bold;
        border:#edfdf9 1px solid;
    }
    .hoverTable td{
        padding-bottom: 12px;
    }

    }
    .hoverTable tr:hover {
        background-color: #eff6f5;
    }

I tried to add this to my CSS but did not work:

    .hoverTable thead
    {
        display: block;
        overflow: auto;
    }

    .hoverTable tbody
    {
        display: block;
        height: 200px;
        overflow: auto;
    }

Any help please ?

mbenjemaa
  • 79
  • 11
  • 1
    This doesn't have anything to do with CakePHP. **https://stackoverflow.com/questions/17067294/html-table-with-100-width-with-vertical-scroll-inside-tbody** | **https://www.google.com/search?q=css%20table%20scrollable%20body**. – ndm Jul 10 '18 at 15:58
  • thanks alot. your reference worked for me. I removed cakephp from tags. – mbenjemaa Jul 10 '18 at 16:39

0 Answers0