Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h2>Animals</h2>
<table data-mobilcolumnaccordeon="1">
    <thead>
        <tr>
            <th>id</th>
            <th data-mobilcolumnvisible="1">Name</th>
            <th>Color</th>
            <th>breed</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Dog</td>
            <td>White</td>
            <td>Afghan Hound</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Cat</td>
            <td>Silver</td>
            <td>American Curl</td>
        </tr>
    </tbody>
</table>
            
          
!
            
              /*
res. tabulka accordeon by Skocik Libor
*/
table[data-mobilcolumnaccordeon] > thead {
        display: none;
    }

    table[data-mobilcolumnaccordeon], table[data-mobilcolumnaccordeon] > tbody {
        display: block;
    }


    table[data-mobilcolumnaccordeon] > tbody tr {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    table[data-mobilcolumnaccordeon] > tbody tr td {
        display: none;
        position: relative;
        padding-left: 140px;
        padding-bottom:1em;
        padding-top:1em;
        cursor: pointer;
        text-align:left !important;
    }

    table[data-mobilcolumnaccordeon] > tbody tr td[data-mobilcolumnvisibleblock] {
        display: flex;
    }

    table[data-mobilcolumnaccordeon] > tbody tr {
        border-bottom: 3px solid #efefef;
        border-left: 3px solid #efefef;
        border-right: 3px solid #efefef;
        margin-top:0.2em;
    }

    table[data-mobilcolumnaccordeon] > tbody td:empty:after {
        content: "\200b"; /* unicode zero width space character */
    }

    table[data-mobilcolumnaccordeon] > tbody tr td[data-mobilcolumnvisible]:before {
        content: "";
    }

    table[data-mobilcolumnaccordeon] > tbody tr td[data-mobilcolumnvisible] {
        display: block;
        position: relative;
        padding-left: 0.7em;
        padding-right: 45px;
        padding-bottom: 1em;
        padding-top: 1em;
        width: auto;
        order: -1;
        cursor: pointer;
        text-align: left;
        border-left: 0;
        border-right: 0;
        border-top: 0;
        background: #efefef;
    }

    table[data-mobilcolumnaccordeon] > tbody tr td:before {
        content: attr(data-mobilcolumnvisiblename) ': ';
        display:block;
        position: absolute;
        left: 5px;
        top: 0;
        width: 130px;
        overflow: hidden;
        font-weight: bold;
        padding-bottom:1em;
        padding-top:1em;
    }

    table[data-mobilcolumnaccordeon] > tbody tr td[data-mobilcolumnvisible]:after {
        content: "";
        position: absolute;
        right: 0;
        top: -2px;
        margin: 16px;
        border: solid #aaa;
        border-width: 0px 2px 2px 0px;
        display: inline-block;
        width: 5px;
        height: 5px;
        padding: 5px;
        transform: rotate(45deg);
    }

    table[data-mobilcolumnaccordeon] > tbody tr td[data-mobilcolumnvisible][data-mobilcolumnvisibleopen]:after {
        top: 5px;
        transform: rotate(225deg);
    }
            
          
!
            
              /*
res. table accordeon by Skocik Libor

settings:
tag table: data-mobilcolumnaccordeon="1"
visible tag thead th: data-mobilcolumnvisible="1"
*/
const main_vut_base_generate_table_mobil_accordeon = {
    is_listeners:{},
    init: function ()
    {
        const taMobil = document.querySelectorAll('table[data-mobilcolumnaccordeon="1"]');
        for (let i = 0; i < taMobil.length; i++) {
            let thMobil = taMobil[i].querySelector('thead tr th[data-mobilcolumnvisible="1"]');
            if (thMobil !== null) {
                let styleTaMobil = window.getComputedStyle(taMobil[i]).getPropertyValue("display");
                if (styleTaMobil == 'block') {
                    let selectTd = 0;
                    let arrColumns = [];
                    let trHeadMobil = taMobil[i].querySelectorAll('thead tr');

                    let trHeadMobilSelIndex = 0;
                    for (let j = 0; j < trHeadMobil.length; j++) {
                        let thHeadMobil = trHeadMobil[j].querySelector('th[data-mobilcolumnvisible="1"]');
                        if (thHeadMobil !== null) {
                            trHeadMobilSelIndex = j;
                            break;
                        }
                    }

                    let thHeadMobil = trHeadMobil[trHeadMobilSelIndex].querySelectorAll('th');
                    for (let k = 0; k < thHeadMobil.length; k++) {
                        arrColumns.push(thHeadMobil[k].innerText);
                        if (thHeadMobil[k].getAttribute('data-mobilcolumnvisible') == true) {
                            selectTd = k;
                        }
                    }

                    let trBodyMobil = taMobil[i].querySelectorAll('tbody tr');
                    for (let i2 = 0; i2 < trBodyMobil.length; i2++) {
                        let tdTbodyMobilVis = trBodyMobil[i2].querySelector('td:nth-child(' + (selectTd + 1) + ')');
                        if (tdTbodyMobilVis != null) {
                            tdTbodyMobilVis.setAttribute('data-mobilcolumnvisible', '1');

                            if (!(i in this.is_listeners)) {
                                this.addListeners(trBodyMobil[i2], tdTbodyMobilVis, selectTd, arrColumns);
                            }

                            for (let j = 0; j < arrColumns.length; j++) {
                                let j2 = j + 1;
                                let workSelectorTd3 = trBodyMobil[i2].querySelector('td:nth-child(' + j2 + ')');
                                if (workSelectorTd3 != null) {
                                    workSelectorTd3.setAttribute('data-mobilcolumnvisiblename', arrColumns[j]);
                                }
                            }
                        }
                    }

                    if (!(i in this.is_listeners)) {
                        this.is_listeners[i] = 1;
                    }
                }
            }
        }
    },

    addListeners: function (trBodyMobilI,tdTbodyMobilVis,selectTd,arrColumns)
    {
        let evIndex = ('ontouchstart' in window) ? 'touchstart' : ((window.DocumentTouch && document instanceof DocumentTouch) ? 'tap' : 'click');
        tdTbodyMobilVis.addEventListener(evIndex, function (e) {
            // detect action
            let testIdTd = 0;
            for (let j = 0; j < arrColumns.length; j++) {
                if (j != selectTd) {
                    testIdTd = j;
                    break;
                }
            }
            let testIdTd2 = testIdTd + 1;

            if (trBodyMobilI.querySelector('td:nth-child(' + testIdTd2 + ')').getAttribute('data-mobilcolumnvisibleblock') == null) {
                tdTbodyMobilVis.setAttribute('data-mobilcolumnvisibleopen', '1');
                for (let j = 0; j < arrColumns.length; j++) {
                    if (j != selectTd) {
                        let workSelectorTd2 = trBodyMobilI.querySelector('td:nth-child(' + (j + 1) + ')');
                        if (workSelectorTd2 != null) {
                            workSelectorTd2.setAttribute('data-mobilcolumnvisibleblock', '1');
                        }

                    }
                }
            } else {
                for (let j = 0; j < arrColumns.length; j++) {
                    trBodyMobilI.querySelector('td:nth-child(' + (j + 1) + ')').removeAttribute('data-mobilcolumnvisibleblock');
                }
                tdTbodyMobilVis.removeAttribute('data-mobilcolumnvisibleopen');
            }
        });
    }
};

main_vut_base_generate_table_mobil_accordeon.init();
window.onresize = function(event) {
    main_vut_base_generate_table_mobil_accordeon.init();
};


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console