Таблица семантического интерфейса пользователя Как сделать так, чтобы правая колонка была зафиксирована при горизонтальной прокрутке - PullRequest
2 голосов
/ 04 ноября 2019

Я создаю таблицу с длинными данными в семантическом интерфейсе. Как сделать так, чтобы последний столбец, содержащий кнопки действий, оставался видимым (фиксированное положение) во время прокрутки? Я искал, но не нашел удовлетворительного решения.

<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet"/>
<div class="ui segment" style="padding: 0px; overflow-x: scroll;"><table class="ui selectable single line compact table slide down visible transition"><thead class=""><tr class="left aligned"><th class="">Name</th><th class="">Type</th><th class="">Percent</th><th class="">Value</th><th class="">Max Value</th><th class="">Begin Date</th><th class="">Expired Date</th><th class="">Selected Product?</th><th class="">Priority</th><th class="">ezPay Available?</th><th class="">merchant Available?</th><th class="">All Merchant?</th><th class=""></th></tr></thead><tbody class=""><tr class="" style="background: rgb(255, 89, 0);"><td class="">fwfewfwe</td><td class="">Default Test</td><td class="">12</td><td class="">0</td><td class="">90000</td><td class="">2019/10/26 15:05</td><td class="">2019/10/26 15:05</td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="">1</td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class=""><div class="ui buttons"><button class="ui mini icon button"><i aria-hidden="true" class="edit outline icon"></i></button><button class="ui mini icon button"><i aria-hidden="true" class="red trash alternate outline icon"></i></button></div></td></tr><tr class="" style="background: rgb(255, 89, 0);"><td class="">123</td><td class="">Default Test</td><td class="">0</td><td class="">69000</td><td class="">0</td><td class="">2019/10/20 14:43</td><td class="">2019/10/21 14:43</td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="">1</td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class=""><div class="ui buttons"><button class="ui mini icon button"><i aria-hidden="true" class="edit outline icon"></i></button><button class="ui mini icon button"><i aria-hidden="true" class="red trash alternate outline icon"></i></button></div></td></tr><tr class="" style="background: rgb(255, 89, 0);"><td class="">grgrb egeh</td><td class="">Default Pulsa Rule Cashback</td><td class="">0</td><td class="">43545345</td><td class="">0</td><td class="">2019/10/20 14:45</td><td class="">2019/10/30 14:45</td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="">1</td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class="center aligned"><i aria-hidden="true" class="times icon"></i></td><td class=""><div class="ui buttons"><button class="ui mini icon button"><i aria-hidden="true" class="edit outline icon"></i></button><button class="ui mini icon button"><i aria-hidden="true" class="red trash alternate outline icon"></i></button></div></td></tr></tbody></table></div>

Вот мой код

1 Ответ

0 голосов
/ 04 ноября 2019

как это?

Я только что добавил position:sticky; и right:0;, top:0; к ::last-child из td.

.ui.table tr td:last-child {
    position: sticky;
    right: 0;
    top: 0;
    background: #333;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet" />
<div class="ui segment" style="padding: 0px; overflow-x: scroll;">
    <table class="ui selectable single line compact table slide down visible transition">
        <thead class="">
            <tr class="left aligned">
                <th class="">Name</th>
                <th class="">Type</th>
                <th class="">Percent</th>
                <th class="">Value</th>
                <th class="">Max Value</th>
                <th class="">Begin Date</th>
                <th class="">Expired Date</th>
                <th class="">Selected Product?</th>
                <th class="">Priority</th>
                <th class="">ezPay Available?</th>
                <th class="">merchant Available?</th>
                <th class="">All Merchant?</th>
                <th class=""></th>
            </tr>
        </thead>
        <tbody class="">
            <tr class="" style="background: rgb(255, 89, 0);">
                <td class="">fwfewfwe</td>
                <td class="">Default Test</td>
                <td class="">12</td>
                <td class="">0</td>
                <td class="">90000</td>
                <td class="">2019/10/26 15:05</td>
                <td class="">2019/10/26 15:05</td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="">1</td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="">
                    <div class="ui buttons">
                        <button class="ui mini icon button"><i aria-hidden="true" class="edit outline icon"></i></button>
                        <button class="ui mini icon button"><i aria-hidden="true" class="red trash alternate outline icon"></i></button>
                    </div>
                </td>
            </tr>
            <tr class="" style="background: rgb(255, 89, 0);">
                <td class="">123</td>
                <td class="">Default Test</td>
                <td class="">0</td>
                <td class="">69000</td>
                <td class="">0</td>
                <td class="">2019/10/20 14:43</td>
                <td class="">2019/10/21 14:43</td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="">1</td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="">
                    <div class="ui buttons">
                        <button class="ui mini icon button"><i aria-hidden="true" class="edit outline icon"></i></button>
                        <button class="ui mini icon button"><i aria-hidden="true" class="red trash alternate outline icon"></i></button>
                    </div>
                </td>
            </tr>
            <tr class="" style="background: rgb(255, 89, 0);">
                <td class="">grgrb egeh</td>
                <td class="">Default Pulsa Rule Cashback</td>
                <td class="">0</td>
                <td class="">43545345</td>
                <td class="">0</td>
                <td class="">2019/10/20 14:45</td>
                <td class="">2019/10/30 14:45</td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="">1</td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="center aligned"><i aria-hidden="true" class="times icon"></i></td>
                <td class="">
                    <div class="ui buttons">
                        <button class="ui mini icon button"><i aria-hidden="true" class="edit outline icon"></i></button>
                        <button class="ui mini icon button"><i aria-hidden="true" class="red trash alternate outline icon"></i></button>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>
...