Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

HTML

              
                <button onclick="adicionaPainelPadrao()" class="btn btn-primary">Add panel  --></button>

<div id="gradeRecipiente" class="container gradeRecipiente">
</div>
              
            
!

CSS

              
                .gradeRecipiente {
            width: 900px;
            height: 600px;
            position: relative;
            background-color: silver;
            padding: 0.5em;
            
        }

        .painelPadrao div.panel-heading {
            cursor: move;
          
        }

        .painelPadrao {
            width: 200px;
            height: 150px;
            background-color: green;
        }

        .panel-body{
          background-color: white;
          height: 100%;
        }
              
            
!

JS

              
                
  function redimencionavel() {
            $(".painelPadrao").resizable({
                grid: 200,
                containment: "parent"
            });
        };
        function arrastavel() {

            $(".painelPadrao").draggable({
                grid: [200, 50],
                containment: "parent",
                cancel: "div.panel-body"

            });
        };

        var numFilhos = 1;
        function adicionaPainelPadrao() {
            //Painel Primário
            var painelPrimario = document.createElement("div");
            painelPrimario.setAttribute("class", "panel panel-primary painelPadrao");
            numFilhos++;
            var idPainelPrimario = "painelPadrao" + (numFilhos);
            painelPrimario.setAttribute("id", idPainelPrimario);
            //Cabeçalho
            var painelCabecalho = document.createElement("div");
            painelCabecalho.setAttribute("class", "panel-heading");
            var t = document.createTextNode("Cabecalho");
            painelCabecalho.appendChild(t);

            //Botão fechar
            var botaoFechar = document.createElement("button");
            botaoFechar.setAttribute("onclick", "ClosePanel(" + idPainelPrimario + ")");
            botaoFechar.setAttribute("class", "btn btn-primary pull-right");
            botaoFechar.setAttribute("style", "padding: 1px 6px");
            t = document.createTextNode("x");
            botaoFechar.appendChild(t);
            painelCabecalho.appendChild(botaoFechar);

            //Botão colapsa
            var botaoColapsar = document.createElement("button");
            botaoColapsar.setAttribute("type", "button");
            botaoColapsar.setAttribute("class", "btn btn-primary pull-right");
            botaoColapsar.setAttribute("data-toggle", "collapse");
            botaoColapsar.setAttribute("data-target", "#painelCorpo" + numFilhos);
            botaoColapsar.setAttribute("style", "padding: 1px 6px");
            t = document.createTextNode("-");
            botaoColapsar.appendChild(t);
            painelCabecalho.appendChild(botaoColapsar);
            painelPrimario.appendChild(painelCabecalho);

            //Corpo
            var painelCorpo = document.createElement("div");
            var idPainelCorpo = "painelCorpo" + (numFilhos);
            painelCorpo.setAttribute("id", idPainelCorpo);
            painelCorpo.setAttribute("class", "panel-body collapse in");
            t = document.createTextNode("Conteúdo...");
            painelCorpo.appendChild(t);
            painelPrimario.appendChild(painelCorpo);

            document.getElementById("gradeRecipiente").appendChild(painelPrimario);
            arrastavel();
            redimencionavel();
        }

       function getChildElementCount(element) {
       var count = 0;
       var childNodes = element.getChildNodes();
       var filho;
       for (filho = 0; filho < childNodes.getLength() ; filho++) {
           if (childNodes.item(child).getNodeType() == Node.ELEMENT_TYPE) {
                count++;
        }
        }
        return count;
        }

              
            
!
999px

Console