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

              
                <p>Recharger la page pour changer les couleurs des formes</p>

<div class="conteneur-flexbox">


<svg width="683px" height="527px" viewBox="0 0 683 527" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	
			
        <g id="Custom-Preset-2" transform="translate(-53.000000, -26.000000)" fill="#D8D8D8" stroke="#232121" stroke-width="4">
					
            <polygon class="forme" id="Path" points="121.488281 57.96875 81.4921875 99.5195312 137.242188 177.785156 236.167969 127.503906 220.085938 68.90625 174.355469 68.90625 158.830078 30"></polygon>
					
            <polygon class="forme" id="Path-2" points="361.597656 36 321 102.359375 376.117188 191.058594 400.441406 124.90625"></polygon>
					
            <polygon class="forme" id="Path-3" points="561.84375 39.0351562 492.117188 51.6953125 485.273438 166.558594 614.109375 191.503906 715.976562 134.332031 733.082031 62.4140625 614.109375 102.296875"></polygon>
					
            <polygon class="forme" id="Path-4" points="97.796875 249.230469 249.394531 249.230469 227.140625 367.035156 173.595703 377.773438 141.882812 284.433594"></polygon>
					
            <polygon class="forme" id="Path-5" points="344.660156 238.417969 344.660156 375.507812 525.285156 375.507812 489.390625 293.605469 434.972656 326.210938 429.933594 247.136719 400 260.535156"></polygon>
					
            <polygon id="Path-6" points="625.59375 279.210938 620.550781 343.355469 648.257812 371.636719 704.316406 332.375 704.316406 297.328125 685.480469 290.871094 680.460938 267.59375 662.433594 274.347656 640.230469 256"></polygon>
					
            <polygon class="forme" id="Path-7" points="101.445312 490.980469 282.367188 444.871094 273.90625 538.640625 238.683594 482.046875 72.7109375 550.148438 56.453125 497.509766"></polygon>
            <polygon class="forme" id="Path-8" points="388.8125 459.335938 373.183594 514.734375 403.609375 550.507812 490.757812 527.636719 517.453125 473.300781 470.097656 496.179688 470.097656 437.730469 445.318359 429 445.318359 473.300781 398.121094 429 368 437.730469"></polygon>
					
            <polygon class="forme" id="Path-9" points="624.234375 446.902344 594 504.34375 656.289062 550.378906 717.4375 504.34375 710.339844 425"></polygon>
        </g>

</svg>
	
	</div>
              
            
!

CSS

              
                body {
	text-align:center;
	font-family:verdana;
}

/*le positionnement du svg dans la page*/
.conteneur-flexbox {
  height: 90vh;
  width: 100%;
  display: flex;
}

svg {
	margin:auto;
}


/*la class appliquée à chaques formes*/
.forme {
	fill: red;
}

/*les class de différentes couleurs*/
.change-color1 {
	fill: orange;
}
.change-color2 {
	fill: green;
}
.change-color3 {
	fill: pink;
}
.change-color4 {
	fill: yellow;
}
.change-color5 {
	fill: grey;
}
.change-color6 {
	fill:#651FFF;
}
              
            
!

JS

              
                
(function($){

	$(document).ready(function() {
		var classes = [ 'change-color1', 'change-color2', 'change-color3', 'change-color4', 'change-color5', 'change-color6' ]; // les class que vous voulez ajouter
		$('.forme').each(function(i) { // l'élément auquel vous voulez ajouter ces class
			$(this).addClass(classes[ Math.floor( Math.random()*classes.length ) ] );
		});
	});

})(jQuery);

              
            
!
999px

Console