Bonjour,

j'essaye désespérément d'aligner verticalement au centre ma div class="questionnaire" dans le script suivant mais je n'y arrive pas. J'ai besoin de votre aide.

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Black Hole Visualization</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
  <div id="blackhole">
    <canvas id="particleCanvas"></canvas>
    <div class="centerHover" id="enterButton"><span>Démarrer</span></div>
  </div>
  <div class="questionnaire" id="questionnaire">
    <div class="slide-container" id="slideContainer"></div>
  </div>
</body>
</html>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
body,
html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; 
}
 
body {
  background-color: rgba(25, 25, 25, 1);
  display: flex; 
  align-items: center; 
  justify-content: center;
}
 
#blackhole {
  height: 100%;
  width: 100%;
  position: relative; 
  display: flex;
  z-index: 1; 
}
 
.centerHover {
  width: 255px;
  height: 255px;
  background-color: transparent;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-top: -128px; 
  margin-left: -128px; 
  z-index: 2; 
  cursor: pointer;
  line-height: 255px; 
  transition: all 500ms;
}
 
.centerHover.open {
  opacity: 0;
  pointer-events: none;
}
 
.centerHover:hover span {
  color: #ddd;
}
 
.centerHover:hover span:before {
  background-color: #ddd;
}
 
.centerHover:hover span:after {
  background-color: #ddd;
}
 
.centerHover span {
  color: #666;
  font-family: serif;
  font-size: 18px;
  position: relative;
  transition: all 500ms;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.centerHover span:before,
.centerHover span:after {
  content: '';
  display: inline-block;
  height: 1px;
  width: 16px;
  background-color: #666;
  transition: all 500ms;
  flex-shrink: 0;
}
 
canvas {
  position: relative; 
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: auto;
}
 
.questionnaire {
  z-index: 5; 
  width: 100%;
  max-width: 390px;
  padding: 20px;
  box-sizing: border-box;
 
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); 
  min-height: fit-content; 
  display: none;
}
 
.questionnaire.active {
  display: block;
  align-items: center;
  justify-content: center;
}
 
.slide-container {
  position: relative;
  min-height: 380px; 
  margin-bottom: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.slide {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  padding: 30px 24px;
  backdrop-filter: blur(12px);
  border: 2px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(75px); 
  border-radius: 20px;
  animation-duration: 0.4s;
  animation-fill-mode: forwards;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: white;
}
 
.slide h2 {
  text-align: center;
  text-transform: uppercase;
  font-size: 20px;
  margin-bottom: 32px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  word-break: break-word; 
  overflow-wrap: break-word; 
}
 
.options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
 
.option-button {
  padding: 14px 22px;
  border-radius: 30px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  backdrop-filter: blur(6px);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  width: auto; 
  max-width: 100%; 
  text-align: center;
  white-space: normal;
  height: 40px;
  transform: none;
}
 
.option-button:hover {
  background: rgba(255, 255, 255, 0.9);
  color: #222325;
  border: 1px solid rgba(0, 0, 0, 0.15);
  transform: translateY(-2px) scale(1.02);
}
 
.final-message {
  font-weight: 500;
  text-align: center;
  font-size: 17px;
  line-height: 1.6;
  word-wrap: break-word; 
  overflow-wrap: break-word; 
  white-space: normal; 
  max-width: 320px;
  margin: 0 auto 24px;
  padding-bottom: 5px;
}
 
.restart-button {
  gap: 10px;
  justify-content: center;
  background: #222325;
  color: white;
  border: none;
}
 
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0%);
    opacity: 1;
  }
}
 
@keyframes slideOut {
  from {
    transform: translateX(0%);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}
Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
function blackhole(element) {
  const container = document.querySelector(element);
  const h = container.offsetHeight;
  const w = container.offsetWidth;
  const cw = w;
  const ch = h;
  const maxorbit = 255; // distance from center
  const centery = ch / 2;
  const centerx = cw / 2;
 
  const startTime = new Date().getTime();
  let currentTime = 0;
 
  const stars = [];
  let collapse = false; // if hovered
  let expanse = false; // if clicked
  let returning = false; // if particles are returning to orbit
 
  // Create canvas
  const canvas = document.createElement("canvas");
  canvas.width = cw;
  canvas.height = ch;
  container.appendChild(canvas);
  const context = canvas.getContext("2d");
 
  context.globalCompositeOperation = "multiply";
 
  function setDPI(canvas, dpi) {
    // Set up CSS size if it's not set up already
    if (!canvas.style.width) canvas.style.width = canvas.width + "px";
    if (!canvas.style.height) canvas.style.height = canvas.height + "px";
 
    const scaleFactor = dpi / 96;
    canvas.width = Math.ceil(canvas.width * scaleFactor);
    canvas.height = Math.ceil(canvas.height * scaleFactor);
    const ctx = canvas.getContext("2d");
    ctx.scale(scaleFactor, scaleFactor);
  }
 
  function rotate(cx, cy, x, y, angle) {
    const radians = angle;
    const cos = Math.cos(radians);
    const sin = Math.sin(radians);
    const nx = cos * (x - cx) + sin * (y - cy) + cx;
    const ny = cos * (y - cy) - sin * (x - cx) + cy;
    return [nx, ny];
  }
 
  setDPI(canvas, 192);
 
  class Star {
    constructor() {
      // Get a weighted random number, so that the majority of stars will form in the center of the orbit
      const rands = [];
      rands.push(Math.random() * (maxorbit / 2) + 1);
      rands.push(Math.random() * (maxorbit / 2) + maxorbit);
 
      this.orbital = rands.reduce((p, c) => p + c, 0) / rands.length;
 
      this.x = centerx; // All of these stars are at the center x position at all times
      this.y = centery + this.orbital; // Set Y position starting at the center y + the position in the orbit
 
      this.yOrigin = centery + this.orbital; // this is used to track the particles origin
 
      this.speed = ((Math.floor(Math.random() * 2.5) + 1.5) * Math.PI) / 180; // The rate at which this star will orbit
      this.rotation = 0; // current Rotation
      this.startRotation =
        ((Math.floor(Math.random() * 360) + 1) * Math.PI) / 180; // Starting rotation
 
      this.id = stars.length; // This will be used when expansion takes place
 
      this.collapseBonus = this.orbital - maxorbit * 0.7; // This "bonus" is used to randomly place some stars outside of the blackhole on hover
      if (this.collapseBonus < 0) {
        // if the collapse "bonus" is negative
        this.collapseBonus = 0; // set it to 0, this way no stars will go inside the blackhole
      }
 
      this.color = "rgba(255,255,255," + (1 - this.orbital / 255) + ")"; // Color the star white, but make it more transparent the further out it is generated
 
      this.hoverPos = centery + maxorbit / 2 + this.collapseBonus; // Where the star will go on hover of the blackhole
      this.expansePos =
        centery + (this.id % 100) * -10 + (Math.floor(Math.random() * 20) + 1); // Where the star will go when expansion takes place
 
      this.prevR = this.startRotation;
      this.prevX = this.x;
      this.prevY = this.y;
 
      // Store original position for returning
      this.originalY = this.yOrigin;
 
      stars.push(this);
    }
 
    draw() {
      if (!expanse && !returning) {
        this.rotation = this.startRotation + currentTime * this.speed;
        if (!collapse) {
          // not hovered
          if (this.y > this.yOrigin) {
            this.y -= 2.5;
          }
          if (this.y < this.yOrigin - 4) {
            this.y += (this.yOrigin - this.y) / 10;
          }
        } else {
          // on hover
          this.trail = 1;
          if (this.y > this.hoverPos) {
            this.y -= (this.hoverPos - this.y) / -5;
          }
          if (this.y < this.hoverPos - 4) {
            this.y += 2.5;
          }
        }
      } else if (expanse && !returning) {
        this.rotation = this.startRotation + currentTime * (this.speed / 2);
        if (this.y > this.expansePos) {
          this.y -= Math.floor(this.expansePos - this.y) / -80; // Slower expansion for better visibility
        }
      }
 
      context.save();
      context.fillStyle = this.color;
      context.strokeStyle = this.color;
      context.beginPath();
      const oldPos = rotate(
        centerx,
        centery,
        this.prevX,
        this.prevY,
        -this.prevR
      );
      context.moveTo(oldPos[0], oldPos[1]);
      context.translate(centerx, centery);
      context.rotate(this.rotation);
      context.translate(-centerx, -centery);
      context.lineTo(this.x, this.y);
      context.stroke();
      context.restore();
 
      this.prevR = this.rotation;
      this.prevX = this.x;
      this.prevY = this.y;
    }
  }
 
  // Event listeners
  const centerHover = document.querySelector(".centerHover");
 
  centerHover.addEventListener("click", function () {
    collapse = false;
    expanse = true;
    returning = false;
    this.classList.add("open");
  });
 
  centerHover.addEventListener("mouseover", function () {
    if (expanse === false) {
      collapse = true;
    }
  });
 
  centerHover.addEventListener("mouseout", function () {
    if (expanse === false) {
      collapse = false;
    }
  });
 
  // Animation loop
  function loop() {
    const now = new Date().getTime();
    currentTime = (now - startTime) / 50;
 
    context.fillStyle = "rgba(25,25,25,0.2)"; // somewhat clear the context, this way there will be trails behind the stars
    context.fillRect(0, 0, cw, ch);
 
    for (let i = 0; i < stars.length; i++) {
      // For each star
      if (stars[i] !== undefined) {
        stars[i].draw(); // Draw it
      }
    }
 
    requestAnimationFrame(loop);
  }
 
  function init() {
    context.fillStyle = "rgba(25,25,25,1)"; // Initial clear of the canvas
    context.fillRect(0, 0, cw, ch);
    for (let i = 0; i < 2500; i++) {
      // create 2500 stars
      new Star();
    }
    loop();
  }
 
  init();
}
 
// Initialize when DOM is loaded
document.addEventListener("DOMContentLoaded", () => {
  blackhole("#blackhole");
});
 
window.onload = function () {
  const flow = {
    start: {
      question: "Nous sommes en 2072, l'univers a évolué. La Terre a été abandonnée au profit de Mars suite à l'évolution des températures rendant la surface de celle-ci invivable.",
      options: {
        continuer: "partie1"
      }
    },
    partie1: {
      question: "L'organisation des pays a été complètement effacée. Cinq conglomérats dirigent l'ensemble de la population restante qui a pu se déplacer vers Mars.",
      options: {
        continuer: "partie2"
      }
    },
    partie2: {
      icon: "fa-brain",
      question: "Where's your focus pointed?",
      options: {
        Deadlines: "deadline",
        "Passion Project": "dream",
        "Self work": "myself"
      }
    },
    adventurous: {
      icon: "fa-shoe-prints",
      question: "What's calling you outward?",
      options: {
        Nature: "nature",
        Creativity: "create",
        Movement: "move"
      }
    },
    Lethargic: {
      icon: "fa-bed",
      question: "Do you want to embrace it or shift it?",
      options: {
        "Embrace it": "embracelazy",
        "Shift it": "movelazy"
      }
    },
    frustrated: {
      icon: "fa-face-angry",
      question: "Where do you feel it most?",
      options: {
        "Mind racing": "mindstorm",
        "Tension in body": "tensionbody"
      }
    },
    disconnected: {
      icon: "fa-circle-question",
      question: "Would you rather...",
      options: {
        Retreat: "retreat",
        "Reach out": "reach"
      }
    },
 
    // Final insights
    alone: {
      message:
        "Solitude can be sacred. Give yourself space without guilt, it’s where nervous systems reset and inner clarity forms."
    },
    withsomeone: {
      message:
        "Social support doesn’t require deep conversation. A simple check-in can be enough to feel seen and reconnected."
    },
    music: {
      message:
        "Let ambient sound fill your space. Familiar rhythms help regulate the nervous system and reduce mental noise."
    },
    deadline: {
      message:
        "Focus works best when it’s contained. Pick one small task, remove distractions, and allow momentum to build naturally."
    },
    dream: {
      message:
        "Your imagination deserves your attention. A small step toward something that excites you shifts your emotional state."
    },
    myself: {
      message:
        "Growth often starts in stillness. Self-work isn’t glamorous, but making space for it signals deep care for your future self."
    },
    nature: {
      message:
        "Natural environments lower cortisol, ease anxiety, and return your brain to its baseline. Step outside, even briefly."
    },
    create: {
      message:
        "Creative expression is emotional regulation. Even doodles, scraps, or silly ideas unlock stored-up energy and insight."
    },
    move: {
      message:
        "Movement metabolizes stress. Shake, walk, stretch, anything to let the tension move through and out."
    },
    emotional: {
      message:
        "Your emotions are messengers, not threats. Sit with them gently, they usually soften once they’re heard."
    },
    lost: {
      message:
        "Mental fog is often a cue for rest or direction change. Allow yourself to pause, not everything must be optimized."
    },
    embracelazy: {
      message:
        "Rest is productive too. Sometimes laziness is your body asking to slow down. Honor it without shame."
    },
    movelazy: {
      message:
        "Shift the vibe with motion. A 2-minute stretch or walk can nudge your energy without pressure to be 'productive.'"
    },
    mindstorm: {
      message:
        "Racing thoughts often mean you need an outlet. Try journaling, breathwork, or even a loud playlist to reset your pace."
    },
    tensionbody: {
      message:
        "Your body remembers what your mind won’t say. Scan for tension and soften what you can. Your body is your ally."
    },
    retreat: {
      message:
        "Pulling back doesn’t mean giving up. It often means you’re listening to your limits — and that’s a form of wisdom."
    },
    reach: {
      message:
        "Vulnerability creates connection. Reaching out may feel risky, but it’s often the first step toward relief and resonance."
    }
  };
 
  const container = document.getElementById("slideContainer");
 
  function createSlide(key) {
    const data = flow[key];
    const slide = document.createElement("div");
    slide.className = "slide";
    slide.style.animationName = "slideIn";
 
    if (data.message) {
      slide.innerHTML = `
        <h2><i class="fa-solid fa-diamond"></i> FINAL INSIGHT</h2>
        <div class="options">
          <div class="final-message">${data.message}</div>
          <button class="option-button restart-button" onclick="startOver()">
            <i class="fa-solid fa-rotate-left"></i><span>Restart</span>
          </button>
        </div>
      `;
      return slide;
    }
 
    slide.innerHTML = `
      <h2><i class="fa-solid ${data.icon}"></i> ${data.question}</h2>
      <div class="options">
        ${Object.entries(data.options)
          .map(
            ([label, nextKey]) =>
              `<button class="option-button" onclick="nextStep('${nextKey}')">${label}</button>`
          )
          .join("")}
      </div>
    `;
 
    return slide;
  }
 
  window.nextStep = function (key) {
    const oldSlide = container.querySelector(".slide");
    if (oldSlide) {
      oldSlide.style.animationName = "slideOut";
      oldSlide.addEventListener("animationend", () => {
        oldSlide.remove();
        const newSlide = createSlide(key);
        container.appendChild(newSlide);
      });
    } else {
      const newSlide = createSlide(key);
      container.appendChild(newSlide);
    }
  };
 
  window.startOver = function () {
    container.innerHTML = "";
    nextStep("start");
  };
 
  const enterButton = document.getElementById("enterButton");
 
  enterButton.addEventListener("click", () => {
    setTimeout(() => {
      enterButton.classList.add("open");
      questionnaire.classList.add("active");
      //nextStep("start");
    }, 5000);
  });
 
  nextStep("start");
};

en version codepen : ici https://codepen.io/new2010/pen/raOOwvN

si quelqu'un a la solution, je suis preneur.

merci