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

              
                <!DOCTYPE html>
<html lang="el">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Brainstorming Gadget</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            overflow-x: hidden;
        }

        #canvas-container {
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 20px auto;
            position: relative;
            width: 100%;
            height: 90vh; /* Μεγαλύτερος καμβάς που καταλαμβάνει σχεδόν όλο το ύψος της οθόνης */
        }

        #canvas {
            width: 95% !important;  /* Χρήση important για να υπερισχύσει οποιοδήποτε άλλο στυλ */
            max-width: 1600px !important;  /* Μεγαλύτερο πλάτος */
            height: 100% !important;
            border: 2px solid #ccc;
            background-color: #f9f9f9;
            position: relative;
            overflow: hidden;
        }

        #centralQuestion {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 24px;
            font-weight: bold;
            text-align: center;
            width: 300px;
            border: 1px solid #ddd;
            padding: 10px;
            background-color: pink;
        }

        .note {
            position: absolute;
            min-width: 150px;
            min-height: 100px;
            padding: 10px;
            background-color: yellow;
            box-shadow: 0 0 5px rgba(0,0,0,0.3);
            border: 1px solid #ddd;
            color: black;
            overflow: hidden;
            resize: both;
            white-space: pre-wrap;
            cursor: move;
        }

        #controls {
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 10px;
            z-index: 10;
        }

        #addNoteBtn, #resetBtn, #downloadBtn {
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            background-color: white;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
    </style>
</head>
<body>

<div id="canvas-container">
    <div id="canvas">
        <div id="centralQuestion" contentEditable="true">Κεντρικό Ερώτημα</div>
        <div id="controls">
            <button id="addNoteBtn">Προσθήκη Σημείωσης</button>
            <button id="resetBtn">Επαναφορά</button>
            <button id="downloadBtn">Λήψη Εικόνας για Εκτύπωση</button>
        </div>
    </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>

<script>
    const colors = ["#ffeb3b", "#ff5722", "#8bc34a", "#03a9f4", "#e91e63"];
    let colorIndex = 0;

    function adjustCanvasSize() {
        const canvas = document.getElementById('canvas');
        canvas.style.width = '1600px';  // Εξαναγκασμός πλάτους
        canvas.style.height = '800px';  // Εξαναγκασμός ύψους
    }

    function addNoteToCanvas(canvas = document.getElementById('canvas')) {
        const note = document.createElement('div');
        note.className = 'note';
        note.contentEditable = true;
        note.style.backgroundColor = colors[colorIndex];
        note.style.top = Math.random() * (canvas.offsetHeight - 100) + 'px';
        note.style.left = Math.random() * (canvas.offsetWidth - 150) + 'px';
        note.dataset.id = Date.now(); // Unique ID
        canvas.appendChild(note);

        makeNoteMovable(note);

        colorIndex = (colorIndex + 1) % colors.length;
    }

    function makeNoteMovable(note) {
        note.addEventListener('mousedown', function(e) {
            const offsetX = e.clientX - note.offsetLeft;
            const offsetY = e.clientY - note.offsetTop;
            note.style.cursor = 'grabbing';

            function onMouseMove(e) {
                note.style.left = e.clientX - offsetX + 'px';
                note.style.top = e.clientY - offsetY + 'px';
            }

            document.addEventListener('mousemove', onMouseMove);

            document.addEventListener('mouseup', function() {
                document.removeEventListener('mousemove', onMouseMove);
                note.style.cursor = 'move';
                constrainNotePosition(note, canvas);
            }, { once: true });
        });
    }

    function constrainNotePosition(note, canvas) {
        const noteRect = note.getBoundingClientRect();
        const canvasRect = canvas.getBoundingClientRect();

        // Περιορισμός σημειώσεων εντός των ορίων του καμβά
        if (noteRect.right > canvasRect.right) {
            note.style.left = canvasRect.width - noteRect.width + 'px';
        }
        if (noteRect.bottom > canvasRect.bottom) {
            note.style.top = canvasRect.height - noteRect.height + 'px';
        }
        if (noteRect.left < canvasRect.left) {
            note.style.left = '0px';
        }
        if (noteRect.top < canvasRect.top) {
            note.style.top = '0px';
        }
    }

    document.getElementById('addNoteBtn').addEventListener('click', function() {
        addNoteToCanvas();
    });

    document.getElementById('resetBtn').addEventListener('click', function() {
        if (confirm('Είστε σίγουροι ότι θέλετε να διαγράψετε όλες τις σημειώσεις;')) {
            document.getElementById('canvas').innerHTML = '<div id="centralQuestion" contentEditable="true">Κεντρικό Ερώτημα</div>';
            colorIndex = 0; // Επαναφορά του δείκτη χρώματος
        }
    });

    document.getElementById('downloadBtn').addEventListener('click', function() {
        html2canvas(document.getElementById('canvas')).then(function(canvas) {
            const link = document.createElement('a');
            link.href = canvas.toDataURL('image/png');
            link.download = 'canvas_image.png';
            link.click();
        });
    });

    // Εξαναγκασμός μεγέθους του καμβά κατά την εκκίνηση
    window.onload = adjustCanvasSize;
</script>

</body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console