The pictures are not showing up in the photo album

I am currently in the process of building a swim image gallery inspired by the Flex Panel Gallery project from Javascript30 (Repo Link). Upon previewing the site in a browser, I encountered an issue where the images extend beyond the frame, leaving only the background of the five flex columns visible on the page.

I'm puzzled as to why the images are being pushed downward out of view in the browser and why the text (which is not organized in column format) only appears after clicking within the columns.

const panels = document.querySelectorAll('.panel');

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

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

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;
  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(https://picsum.photos/id/10/2500/1667);
}

#second-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

#third-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

#fourth-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

#fifth-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

.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 div p {
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
  font-size: 2em;
}

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

.panel.open {
  flex: 5;
  font-size: 40px;
}
<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">
        <div id="first-panel">
          <p>Join</p>
          <p>This</p>
          <p>Quarter!</p>
        </div>
      </div>
      <div class="panel">
        <div id="second-panel">
          <p>Swimming</p>
          <p>Is</p>
          <p>Fun!</p>
        </div>
      </div>
      <div class="panel">
        <div id="third-panel">
          <p>Every</p>
          <p>Husky</p>
          <p>Is Welcome!</p>
        </div>
      </div>
      <div class="panel">
        <div id="fourth-panel">
          <p>Recreational</p>
          <p>Swim</p>
          <p>Atmosphere!</p>
        </div>
      </div>
      <div class="panel">
        <div id="fifth-panel">
          <p>Best</p>
          <p>Club</p>
          <p>To Stay Fit!</p>
        </div>
      </div>
    </div>
    <script src="index.js">
    </script>
  </body>

</html>

Answer №1

After reviewing the repository, it is recommended to implement the image background on the parent div, similar to the following example:

<div class="panel" id="first-panel">
  <p>Join</p>
  <p>This</p>
  <p>Quarter!</p>
</div>

const panels = document.querySelectorAll('.panel');

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

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

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;
  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(https://picsum.photos/id/10/2500/1667);
}

#second-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

#third-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

#fourth-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

#fifth-panel {
  background-image: url(https://picsum.photos/id/10/2500/1667);
}

.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 div p {
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
  font-size: 2em;
}

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

.panel.open {
  flex: 5;
  font-size: 40px;
}
<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>Is</p>
        <p>Fun!</p>
      </div>
      <div class="panel" id="third-panel">
        <p>Every</p>
        <p>Husky</p>
        <p>Is Welcome!</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>
    </div>
    <script src="index.js">
    </script>
  </body>

</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

rearrange results in ng-repeat based on specified array in AngularJS

Currently delving into Angularjs and have a quick query: I recently received an array from a user which looks like this: userPreferences = [7,5,4] Additionally, I am working with an object that uses ng-repeat to showcase various news items. The object s ...

Tips for adjusting the minimum attribute within an input field with jQuery

In my form, I have an input field with arrows (up and down). Next to it, there are two buttons: + and -. When I click on the input field and then use the arrow, the system retrieves the value from a dropdown list, which works fine. However, when I use the ...

"Encountering a 404 error when submitting a contact form in Angular JS

Looking to set up a contact form for sending emails with messages. Currently diving into Angular Express Node Check out the controller code below: 'use strict'; /** * @ngdoc function * @name exampleApp.controller:ContactUsCtrl * @descripti ...

Prevent the cascading of CSS styles on child list items

When constructing my menu, I have organized it using the following HTML structure: <div id=”navigation”> <ul> <li class=”level1”>Top Level Menu item <div class=”sublevel”> <ul> ...

Troubleshooting: Angular CLI project encountering issues on Internet Explorer

Today, I encountered an issue when attempting to create a new project using the Angular CLI. An exception is thrown on IE11 and the console displays the following error message: SCRIPT5007: Unable to get property 'call' of undefined or null ref ...

The property of userNm is undefined and cannot be set

When attempting to retrieve a value from the database and store it in a variable, an error is encountered: core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Cannot set property 'userNm' of undefined TypeError: Cannot set property &apos ...

What is the best way to ensure that the maximum price is mandatory when entering a minimum price?

Essentially, the process works like this: if a person inputs a minimum price but forgets to input a maximum price, then presses search, it will not perform the search and a message will appear next to the max price field reminding them to enter a maximum ...

What is the best way to center align the div container horizontally?

Trying to center the #container but all methods have failed. How can I achieve centering using only CSS? body { text-align:center; } <div id="app"> <div id="container"><div id="container_red" style="position:absolute;left:0"> ...

Tips on transferring a value from one JavaScript file to another JavaScript file

Currently, I am able to pass parameters from one JavaScript file to another using the jQuery method "$.getScript". For example, in the "secondJavaScript.js" file, I use a $.getScript call to invoke the function callMemoPage() from "firstJavaScript.js", p ...

What is the best way to check the CSS attributes of a React component with react-testing-library?

I understand the philosophy behind the react-testing-library, but I am having difficulty implementing it with CSS properties. For instance, consider a basic toggle component that changes its background color when clicked: import React, { useState } from ...

AngularJS: Blocking access to specific state for users

I am currently in the process of developing an application using sails.js for the backend and Angular for the frontend. My goal is to restrict access to the admin control page for unauthorized users. I have come across several solutions, but none of them s ...

Using Vue.js with typeahead feature: the missing link

I'm currently working on creating a form with autocomplete functionality. The goal is to have a user input part of a name, which will then trigger suggestions from our database. Upon selecting a suggestion, I want the entire form to be populated with ...

Modify the CSS when CKEditor is in focus

Implementing CKEditor in a symfony project using the FOS\CKEditor-bundle 1.2. I want to style the entire element containing CKEditor with a border when it is focused, similar to how questions are written or answered on Stackoverflow. By referencing a ...

Executing a JavaScript function within PHP code

I am working on a foreach loop that creates a series of checkboxes with items from a database. Currently, none of the checkboxes are pre-checked and each time a user checks one, a JavaScript function is called. Now, my clients want the first checkbox to b ...

Why isn't the AngularJS injected view resizing to fit the container?

As a novice delving into a project in the MEAN stack, I'm encountering inconsistent HTML previews. When I view it independently versus running it from the project, the display varies. Here's the intended appearance (in standalone preview): imgu ...

Is it possible to extract the version_name using the version_code of an android package?

Is it possible to retrieve the version_name by using the version_code of an Android package? For instance: 'com.nianticlabs.pokemongo' version_code: 2017121800 => version_name: 0.87.5 I'm looking for a function that can accomplish th ...

Updating Documents in CouchDB

Can you please confirm if this is the correct method for updating a document in couchDB? To update a document (let's call it fooDoc), I must pass "_rev". First, I need to retrieve that document using the following code (foo.get). Then, in the callbac ...

Replace the function if it is specified in the object, otherwise use the default functionality

Having a calendar widget written in TypeScript, I am able to bind a listener to a separate function. However, I desire this separate function to have default functionality until someone overrides it in the config object passed to the constructor. Within th ...

How can I make my div disappear when I click outside of it using jQuery? I am finding the solution on Stack Overflow to be confusing

Utilizing jQuery to conceal a DIV upon clicking outside of it Although I've heard positive feedback about this method, I'm uncertain about its functionality. Can someone provide an explanation? I understand that .has() identifies elements contai ...

Having trouble detecting the Selection event of a Dropdown List upon loading

When a user chooses an option from the dropdown menu, I need to capture the selected item and perform an action: $("#user-list").on("change", function() { var selectedUser = $(this).find(":selected").text(); // Perform action with the selected us ...