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

+ 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 class="microwave">
  <div class="door">
    <div class="glass"></div>
    <div class="handle"></div>
  <div class="menu">
    <div class="screen">
      <span class="progress"></span>
    <button class="start">Start</button>
    <button class="clear">Clear</button>
  <div class="smoke">
    <span class="s0"></span>
    <span class="s1"></span>
    <span class="s2"></span>
    <span class="s3"></span>
    <span class="s4"></span>
    <span class="s5"></span>
    <span class="s6"></span>
    <span class="s7"></span>
    <span class="s8"></span>
    <span class="s9"></span>


body {
  margin: 0;
  width: 100%;
  height: 100%;

body {
  background: linear-gradient(to right, #007991, #78ffd6); /* */

.microwave {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  background: grey;
  width: 90vmin;
  height: 50vmin;
  transform: translate(-50%, -50%);

.microwave::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 4vmin;
  width: calc(100% - 8vmin);
  height: 75%;
  background: black;
  transform: translateY(-50%);
  border-radius: 2vmin;

.door {
  position: relative;
  flex: 0 0 75%;
  border-right: solid 3px white;

.handle {
  position: absolute;
  top: calc(5vmin - 1.5px);
  right: 3.5vmin;
  width: 4vmin;
  height: calc(100% - 10vmin);
  background: grey;
  border-radius: 2vmin;
  border: solid 3px white;

.glass {
  position: absolute;
  top: 50%;
  left: 8vmin;
  width: 70%;
  height: calc(70% - 5vmin);
  background-color: white;
  transform: translateY(-50%);

.running .glass {
  background-color: lightyellow;

.menu {
  flex: 0 0 25%;
  position: relative;

.clear {
  position: absolute;
  bottom: 17.5%;
  right: 4.5vmin;
  width: 80%;
  color: white;
  height: 5vmin;
  background: transparent;
  border: none;
  text-transform: uppercase;
  text-align: center;
  font-size: 3.5vmin;

.clear { 
  display: none; 
  color: red;

.running .start { display: none; }
.running .clear { display: block; }

.screen {
  position: absolute;
  top: 20%;
  right: 6.5vmin;
  width: 60%;
  height: 5vmin;
  background: white;

.progress {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  background: #78ffd6;
  transform-origin: 0 50%;
  transform: scaleX(0);

.running .progress {
  transform: scaleX(1);
  transition: transform 2s linear;

.smoke {
	position: absolute;
	width: 0; 
  height: 0;
	left: 37%; 
  top: 8.5vmin;

.smoke span { 
  display: block;
	position: absolute;
	bottom: -35px; left: 50%; margin-left:-20px;
	height: 0px; width: 0px;
	border: 35px solid #4b4b4b;
	border-radius: 35px;
	left: -14px; opacity: 0;
	transform: scale(0.2);

@keyframes fumeeG {
	0%   { transform: scale(0.2) translate(0, 0) }
	10%  { opacity: 1; transform: scale(0.2) translate(0, -5px) }
	100% { opacity: 0; transform: scale(1) translate(-20px, -130px) }

@keyframes fumeeD {
	0%   { transform: scale(0.2) translate(0, 0) }
	10%  { opacity: 1; transform: scale(0.2) translate(0, -5px) }
	100% { opacity: 0; transform: scale(1) translate(20px, -130px) }

.cancel .smoke .s0 { animation: fumeeG 10s 0s }
.cancel .smoke .s1 { animation: fumeeD 10s 1s }
.cancel .smoke .s2 { animation: fumeeG 10s 2s }
.cancel .smoke .s3 { animation: fumeeD 10s 3s }
.cancel .smoke .s4 { animation: fumeeG 10s 4s }
.cancel .smoke .s5 { animation: fumeeD 10s 5s }
.cancel .smoke .s6 { animation: fumeeG 10s 6s }
.cancel .smoke .s7 { animation: fumeeD 10s 7s }
.cancel .smoke .s8 { animation: fumeeG 10s 8s }
.cancel .smoke .s9 { animation: fumeeD 10s 9s }


Pour cet exercice, vous n'avez qu'à ajouter du JS (Nul besoin de modifier le HTML ou le CSS).

1. Lorsque la transition sur l'élément progrès débute, il faut déclencher le son 'marche'.
2. Lorsque la transition est terminée, retirer la classe 'en-marche' sur l'élément <body>, mettre le son 'marche' à pause et déclencher le son 'ding'.
3. Si l'usager appuie sur le bouton 'clear' pendant la transition, mettre le son 'marche à pause', retirer la classe 'en-marche' sur l'élément <body>. La transition sera ainsi cancellée. Écouter cet événement et si l'elapsedTime est inférieur à '2' (soit la durée de l'animation), ajouter la classe 'oups' au <body>.

Résultat attendu 👉

Bonne chance

const start = document.querySelector('.start');
var ding = new Audio('');
var marche = new Audio('');

start.addEventListener('click', function() {