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="buttons">
    <button id="foldBtn" data-folder>Tout déplier</button>
    <button id="unfoldBtn">Tout replier</button>
</div>
<div id="container">
    <div>
        <input type="checkbox" id="folder1" name="folders" value="1" />
        <h2><label for="folder1">De quoi s'agit-il ?</label></h2>   
        <div>
            <p>
                L'émancipation est l'acte par lequel un mineur est juridiquement assimilé à un majeur et peut normalement accomplir seul les actes nécessitant la majorité légale.
            </p><p>
                L'émancipation d'un mineur a lieu essentiellement sur décision du juge des tutelles à la demande de son ou ses parents, ou en cas de tutelle du mineur, du conseil de famille.
            </p><p>
                Le mineur doit avoir 16 ans révolus. 
            </p>
        </div>
    </div>

    <div>
        <input type="checkbox" id="folder2" name="folders" value="2" />
        <h2><label for="folder2">Procédure</label></h2> 
        <div>
            <p> 
                L'émancipation de l'enfant peut être demandée ensemble par ses 2 parents.
            </p><p>
                Elle peut aussi être demandée par un seul des 2 parents :
            </p>
            <ul>
                <li>
                    en cas de désaccord entre eux,
                </li>
                <li>
                    ou si un seul d'entre eux est titulaire de l'exercice de l'autorité parentale.
                </li>
            </ul>
        </div>
    </div>

    <div>
        <input type="checkbox" id="folder3" name="folders" value="3" />
        <h2><label for="folder3">Effets</label></h2>    
        <div>
            <p>
                Le mineur émancipé est capable, comme un majeur, de tous les actes de la vie civile.
            </p><p>
                Il peut conclure un contrat de travail, signer une vente, contracter un crédit...
            </p><p>
                Certains actes jugés graves lui sont cependant interdits.
            </p>
        </div>
    </div>

</div>
              
            
!

CSS

              
                body { margin: 1rem 2rem; background-color: #666; }
#container { background-color: #eee; } 
div.buttons { text-align: right; margin-bottom: 1rem; }
#container input[type="checkbox"] { display: none }
#container > div { margin:0; padding: 0.3rem; border: 1px solid #666; }
#container > div:not(:last-of-type) { border-bottom: none; }
#container > div h2 { margin:0; padding: 0.3rem 1rem; background-color: burlywood; }
#container > div h2 label { 
	position: relative;
	display: block;
	margin-right: 1rem;
}
#container > div h2 label { display: inline-block; width: 100%; }
#container > div h2 label::after { content: '⯆'; position: absolute; right: 0; }
#container > div input[type="checkbox"]:checked + h2 label::after { content: '⯅'; }
#container input[type="checkbox"] + h2 + div {
	height: 0;
	overflow: hidden;
}
#container input[type="checkbox"]:checked + h2 + div { height: 100%; }

              
            
!

JS

              
                (function() {
	'use strict';
	const checkboxes = document.querySelectorAll('#container input[type="checkbox"]');
	if(checkboxes != null) {

		const buttons = document.querySelectorAll('div.buttons button');
		if(buttons != null) {
			for(var i=0, iMax=buttons.length; i<iMax; i++) {
				buttons[i].addEventListener('click', function(event) {
					console.log('On clique sur un bouton');
					const value = event.target.hasAttribute('data-folder');
					for(var i=0, iMax= checkboxes.length; i<iMax; i++) {
						checkboxes[i].checked = value;
					}
					event.preventDefault();
				});
			}
		}

	}
})();

              
            
!
999px

Console