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


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


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.


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.

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.


                <div id="canvas">Click</div>


                #canvas {
    margin: auto;
    position: relative;
    width: 400px;
    height: 200px;
    text-align: center;
    padding-top: 200px;
    border: solid thin black;
span {
    width: 2px;
    height: 2px;
    background-color: black;


                var $ = (s) => document.querySelector(s);

$('#canvas').onclick = function (e) {
    // Ces deux valeurs donnent la distance du click
    // par rapport à la bordure du div
    console.log(e.pageX - this.offsetLeft,
                e.pageY - this.offsetTop);
    // On vide le div
    this.innerHTML = '';
    // Les quatre directions à parcourir (en coordonnées projectives)
    var dir = { 'horizontal': [1, 0],
                'diagonal': [1, 1],
                'vertical': [0, 1],
                'antidiagonal': [-1, 1] };
    // On boucle sur chaque direction
    for (var d in dir) {
        // Pour chaque direction, on boucle sur une longueur double
        // par rapport au conteneur
        for (var i = -99; i < 100; i++) {
            // Les coordonnées du prochain point
            var x = e.pageX - this.offsetLeft + 4 * i * dir[d][0],
                y = e.pageY - this.offsetTop + 4 * i * dir[d][1];
            // Si le point est à l'intérieur du conteneur,
            // on l'ajoute au div
            if (x > 0 && x < 400 && y > 0 && y < 400) {
                var dot = document.createElement('span');
       = 'absolute';
       = x + 'px';
       = y + 'px';