Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="w-layout-grid drag-grid">
</div>
    <div id="pompelmo" class="draggable" style="position: relative; left: 700px; top: 140px;">
        <img src="https://cdn.shopify.com/s/files/1/0498/6958/6597/files/1_pompelmo.png?v=1700317952" alt="" class="card-img pompelmo" style="width: 160px; height: auto;">
    </div>
    <div id="untersetzer" class="draggable" style="position: relative; left: 120px; top: 200px;">
        <img src="https://cdn.shopify.com/s/files/1/0498/6958/6597/files/1_Untersetzer.png?v=170014153" class="card-img untersetzer" style="width: 280px; height: auto;">
    </div>
    <div id="teller" class="draggable" style="position: relative; left: 360px; top: -150px;">
        <img src="https://cdn.shopify.com/s/files/1/0498/6958/6597/files/StudioSicily-1024715_hr.png?v=1700314620" class="card-img teller" style="width: 380px; height: auto;">
    </div>
    <div id="tarte" class="draggable" style="position: relative; left: -290px; top: -847px;">
        <img src="https://cdn.shopify.com/s/files/1/0498/6958/6597/files/1_Tarte.png?v=1700316845" alt="" class="card-img tarte" style="width: 100px; height: auto;">
    </div>
    <div id="diving" class="draggable" style="position: relative; left: 150px; top: -700px;">
        <img src="https://cdn.shopify.com/s/files/1/0498/6958/6597/files/1_Diving_into_pool.png?v=1700141535" class="card-img diving" style="width: 190px; height: auto;">
    </div>
              
            
!

CSS

              
                <style>
    /* Stil für den Drag-and-Drop-Container */
    .drag-grid {
        position: relative;
        width: 100%;
    }

    /* Stil für draggbare Elemente */
    .draggable {
        position: absolute;
        cursor: pointer;
    }

    /* Stil für die Bilder */
    .card-img {
        max-width: 100%;
        height: auto;
    }

    /* Hover-Effekt mit 3° Drehung */
    .draggable:hover {
        transform: rotate(3deg);
        transition: transform 0.3s ease;
    }

    /* Responsive Verhalten: Drag-and-Drop auf mobilen Geräten deaktivieren */
    @media (max-width: 768px) {
        .draggable {
            display: none;
        }
    }
</style>
              
            
!

JS

              
                <script>
document.addEventListener('DOMContentLoaded', function() {
    document.querySelectorAll('.draggable').forEach(el => {
        el.addEventListener('mousedown', function(e) {
            // Berechnen Sie den Abstand vom linken und oberen Rand des Elements
            var offsetX = e.clientX - el.getBoundingClientRect().left;
            var offsetY = e.clientY - el.getBoundingClientRect().top;

            function mouseMoveHandler(e) {
                // Setzen Sie die Position des Elements auf die Mausposition minus den berechneten Abstand
                el.style.left = (e.clientX - offsetX) + 'px';
                el.style.top = (e.clientY - offsetY) + 'px';
            }

            function reset() {
                // Entfernen Sie die Event-Listener, wenn die Maus losgelassen wird
                window.removeEventListener('mousemove', mouseMoveHandler);
                window.removeEventListener('mouseup', reset);
            }

            // Fügen Sie Event-Listener für Mausbewegung und Mausloslassen hinzu
            window.addEventListener('mousemove', mouseMoveHandler);
            window.addEventListener('mouseup', reset);
        });
    });
});
</script>
              
            
!
999px

Console