Как переместить элемент секции ниже ряда флекс-контейнеров - PullRequest
0 голосов
/ 23 апреля 2020

У меня есть галерея изображений, где я пытаюсь добавить раздел из двух текстовых полей и кнопку под строкой div, которые являются flex-контейнерами. Прямо сейчас раздел расположен так, что он находится рядом со столбцами, когда я хочу, чтобы он находился под ними. Мои различные попытки решить эту проблему позволили мне переместить секцию вдоль направления столбца, но она находится непосредственно рядом со строкой.

"use strict";
const panels = document.querySelectorAll('.panel');

function toggleOpen() {
  console.log('Test');
  this.classList.toggle('open');
}

function toggleActive(flexPanel) {
  console.log(flexPanel.propertyName);
  if (flexPanel.propertyName.includes('flex')) {
    this.classList.toggle('open-active');
  }
}

function appendParagraph() {

}

panels.forEach(panel => panel.addEventListener('click', toggleOpen));
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
body {
  box-sizing: border-box;
  background: lightblue;
  font-family: "Source Sans Pro", sans-serif;
  font-size: 20px;
  font-weight: 200;
  margin: 0;
}

body, body:before, body:after {
  box-sizing: inherit;
}

.image-panels {
  min-height: 100vh;
  overflow: hidden;
  display: flex;
}

.panel {
  display: flex;
  background: #6B0F9C;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1);
  color: white;
  text-align: center;
  align-items: center;
  transition:
    font-size 0.7s cubic-bezier(0.51, -0.19, 0.7, -0.11),
    flex 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11),
    background 0.2s;
  font-size: 20px;
  background-size: cover;
  background-position: center;
  flex: 1;
  justify-content: center;
  flex-direction: column;
}

#first-panel {
  background-image: url("img/butterfly-pav-pool.jpg");
}

#second-panel {
  background-image: url("img/students-pav-pool.jpg");
}

#third-panel {
  background-image: url("img/husky-swimming.jpg");
}

#fourth-panel {
  background-image: url("img/dock-diving.jpg");
}

#fifth-panel {
  background-image: url("img/ima-pool.jpg");
}

.panel > * {
  display: flex;
  margin: 0;
  width: 100%;
  transition: transform 0.5s;
  flex: 1 0 auto;
  justify-content: center;
  align-items: center;
}

.panel > *:first-child {
  transform: translateY(-100%);
}

.panel.open-active > *:first-child {
  transform: translateY(0);
}

.panel > *:last-child {
  transform: translateY(100%);
}

.panel.open-active > *:last-child {
  transform: translateY(0);
}

.panel p {
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
  font-size: 5em;
  font-family: "Source Sans Pro", sans-serif;
  background: rgba(0, 0, 0, 0.3);
}

.panel p:nth-child(2) {
  font-size: 10em;
}

.panel.open {
  flex: 5;
  font-size: 40px;
}

#replace-words {

}
<!DOCTYPE html>
<!--
  Name: Jason Xu
  Date: 04.21.2020
  Section: CSE 154 AI

  This is the index.html for my image gallery.
-->
<html lang="en">

  <head>
    <meta charset="utf-8">
    <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
    <title>Swim Club Image Gallery</title>
  </head>

  <body>
    <div class="image-panels">
      <div class="panel" id="first-panel">
        <p>Join</p>
        <p>This</p>
        <p>Quarter!</p>
      </div>
      <div class="panel" id="second-panel">
        <p>Swimming</p>
        <p class="main-tagline">Is</p>
        <p>Fun!</p>
      </div>
      <div class="panel" id="third-panel">
        <p>Every</p>
        <p>Husky</p>
        <p>Is Welcome To Join!</p>
      </div>
      <div class="panel" id="fourth-panel">
        <p>Recreational</p>
        <p>Swim</p>
        <p>Atmosphere!</p>
      </div>
      <div class="panel" id="fifth-panel">
        <p>Best</p>
        <p>Club</p>
        <p>To Stay Fit!</p>
      </div>
      <section id="replace-words">
        <label for="input-word">Type the word you want to replace:</label>
        <input type="input-box" id="input-word">
        <br>
        <label for="replace-word">Type the replacement word:</label>
        <input type="replace-box" id="replace-word">
        <br>
        <button type="button">Click to replace the word!</button>
      </section>
    </div>
    <script src="index.js">
    </script>
  </body>

</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...