What steps can I take to bring this idea to life in my gallery?

Currently, I am facing a roadblock while transitioning my design concept into actual code. My main concern lies with creating this art piece. Although the gallery is up and running with all the images in place, I'm encountering difficulties with the spacing, color scheme beneath the pictures, and adding captions. Whenever I try to include captions, the images tend to spread out more than expected. Can someone assist me in executing this vision? My primary focus is on fine-tuning the spacing, colors, and captions, keeping in mind that the gallery already boasts responsive features. Any form of help would be greatly appreciated. Thank you for your time and consideration. Below is the code I've put together so far. Click on the "Full Page" link to view the snippet.

.intro {
    margin-top: 70px;
    text-align: center;
    margin-bottom: 40px;
  }
  
  .gallery_container-all {
    width: 95%;
    margin: 20px auto;
    height: auto;
    margin-bottom: 40px;
  }
  #outside{
      background-color: lightcyan;
  }
  .gallery_container {
    width: calc(33% - 6px);
    overflow: hidden;
    height: fit-content;
    margin: 3px;
    padding: 0;
    display: inline-block;
    position: relative;
    float: none;
    border-radius: 5px;
    background-color: black;
  }
  
  img {
    width: 100%;
    transition-duration: 0.3s;
    max-width: 100%;
    display: block;
    overflow: hidden;
    cursor: pointer;
  }
  
  .gallery_title {
    position: absolute;
    display: block;
    cursor: pointer;
    top: 35%;
    display: none;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 1.6em;
    transition-duration: 0.3s;
  }
  
  .gallery_text {
    position: absolute;
    top: 70%;
    cursor: pointer;
    max-width: 80%;
    text-align: center;
    left: 50%;
    font-size: 1em;
    display: none;
    margin-right: -50%;
    transition-duration: 0.3s;
    transform: translate(-50%, -50%);
  }
  
  .gallery_container:hover img {
    transform: scale(1.2);
    transition-duration: 0.3s;
    opacity: 0.5;
  }
  
  .gallery_container:hover span {
    color: white;
    display: block;
    transition-duration: 0.3s;
  }
  
  @media only screen and (max-width: 800px) {
  .intro {
      margin-top: 40px;
  }
  .gallery_container {
      width: 100%;
      margin-left: auto;
      margin-right: auto;
  }
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
        <div id = "outside">
    <div class="intro">
        <h1>Earth</h1>
        <h4>Here are some pictures of Earth</h4>
      </div>
      <div class="gallery_container-all">
        <div class="gallery_container thefirst">
          <img src="https://images.pexels.com/photos/5554114/pexels-photo-5554114.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here">
        </div>
        <div class="gallery_container">

        </div>
        <div class="gallery_container thesecond">
          <img src="https://images.pexels.com/photos/4300360/pexels-photo-4300360.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here">
        </div>
        <div class="gallery_container thethird">
          <img src="https://images.pexels.com/photos/4555540/pexels-photo-4555540.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here">
        </div>
        <div class="gallery_container">

        </div>
        <div class="gallery_container thefourth">
          <img src="https://images.pexels.com/photos/5254697/pexels-photo-5254697.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here">
        </div>
      </div>
    </div>
    <script src="script.js"></script>
  </body>
</html>

Answer №1

This solution will get the job done.

.intro {
  margin-top: 70px;
  text-align: center;
  margin-bottom: 40px;
}

.gallery_container-all {
  width: 95%;
  margin: 20px auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 50px;
}

#outside {
  background-color: lightcyan;
}

.gallery_container {
  width: 60%;
  overflow: hidden;
  border-radius: 5px;
}

.gallery_container:nth-last-of-type(2n + 1) {
  justify-self: end;
}

img {
  width: 100%;
  transition-duration: 0.3s;
  max-width: 100%;
  display: block;
  overflow: hidden;
  cursor: pointer;
}

img:hover {
  transform: scale(1.2);
  transition-duration: 0.3s;
  opacity: 0.9;
}

.content {
  position: relative;
  z-index: 50;
  padding-top: 60px;
  background-color: lightcyan;
}

.content h3 {
  margin: 0;
  text-align: center;
}

.content h3::before {
  content: "";
  position: absolute;
  background-color: orangered;
  border-radius: 500px;
  width: 150px;
  height: 20px;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
}

@media only screen and (max-width: 1000px) {
  .gallery_container {
    width: 100%;
  }
}
<div id="outside">
  <div class="intro">
    <h1>Earth</h1>
    <h4>Here are some pictures of Earth</h4>
  </div>
  <div class="gallery_container-all">
    <div class="gallery_container thefirst">
      <img src="https://images.pexels.com/photos/5554114/pexels-photo-5554114.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here" />
      <div class="content">
        <h3>Caption 🤘</h3>
      </div>
    </div>
    <!-- <div class="gallery_container"></div> -->
    <div class="gallery_container thesecond">
      <img src="https://images.pexels.com/photos/4300360/pexels-photo-4300360.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here" />
      <div class="content">
        <h3>Caption 🤘</h3>
      </div>
    </div>
    <div class="gallery_container thethird">
      <img src="https://images.pexels.com/photos/4555540/pexels-photo-4555540.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here" />
      <div class="content">
        <h3>Caption 🤘</h3>
      </div>
    </div>
    <!-- <div class="gallery_container"></div> -->
    <div class="gallery_container thefourth">
      <img src="https://images.pexels.com/photos/5254697/pexels-photo-5254697.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Image description goes here" />
      <div class="content">
        <h3>Caption 🤘</h3>
      </div>
    </div>
  </div>
</div>

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

Issue with Initiating Html5Qrcode Scanner Automatically Following Form Submission

I'm currently utilizing the Html5Qrcode scanner within a WordPress plugin to scan barcodes for products. My workflow involves: 1. Initiating the Html5Qrcode scanner and scanning a barcode. 2. Using the decoded barcode value to search for and display ...

jQuery - Incorrect folder path for image replacement

I have a specific request to change the image paths in multiple .html pages, redirecting them from the default folder to another folder. After implementing code from an external javascript file successfully, I am encountering an error where the HTML sou ...

Shift the sleek navigation arrows to the interior of the slides

Is there a way to relocate the navigation arrows on the slider images? I have tried various methods found online with no success. Currently using ASP.NET, but doubt it matters. Employing the latest version of SLICK. Here is the HTML code snippet: <%@ ...

Is it possible to store an HTML element tag in a variable?

I've been learning JavaScript on w3schools and freecodecamp, but I stumbled upon something in w3schools that has me puzzled. Can someone please explain why this particular code snippet works? The variable "text" is declared as containing the string " ...

Execute JavaScript code once all the AngularJS template directives are fully loaded

On my HTML page, I am utilizing AngularJS template directives. Here is an example of how it looks: <div class="row"> <div class="col-sm-12"> <div logo></div> <div login-card></div> ...

Unable to render the JSON data that was retrieved from a jQuery AJAX request

I am having trouble displaying JSON data that is returned from an AJAX call. Can someone please assist me? I am new to this. $.ajaxSetup({ cache: false, timeout: 5000 }); //String.prototype.toJSON; var the_object = {}; function concatObject(obj) { ...

Passing a PHP array to a JavaScript function using a button click event in an HTML form

It seems there was some confusion in my approach. I'm working with a datatable that has an edit button at the end. Clicking on this button opens a modal, and I want to pass the data from the table to the modal. While I can send it as a single variabl ...

Is it possible to align a row so that it is centered based on one of the columns in the row?

Calling all experts in CSS and HTML: Let's say I have 3 columns in a row, each with a different size (refer to the image). Now, picture this - I want to center the 2nd column right in the middle of my page. If I simply use justify-content: center to ...

What is the best method for aggregating multiple JSON responses into a single array?

I am struggling to get my data in the desired format of [{..},{..},{..}]. I have created an empty array using const arr = [], but when I push all JSON data into this array, the output shows as separate arrays. How can I fix this issue? // const arr = [] co ...

What sets apart Material UI's gutterBottom from a paragraph?

Can you explain the distinction between these two options? While exploring the Typography Component API, I noticed that both the gutterBottom and paragraph props seem to serve the same purpose. If set to true, the margin bottom will be 0. You can find mor ...

Can side effects be safely incorporated within the callback of the useState hook?

Consider this scenario: const [value, setValue] = useState(false); const setSomething = (val) => { setValue((prev) => { fn(); dispatch(action); // or any other side effect return prev + val; }); }; Is it acceptable and in line with ...

Problem with CSS dotted borders appearing as dashed in Chrome when applied to adjacent columns in a table

After testing the code on both Chrome and Firefox browsers, I noticed that they display the border differently. In Chrome, there is a dash in between adjacent cells while in Firefox, there are no dashes rendering. Can anyone suggest a solution to fix thi ...

What is the best way to send a JavaScript variable to a GraphQL query?

I'm struggling with making my super simple GraphQl query dynamic based on input. The query is straightforward, but I need to replace the hardcoded string of "3111" with a value from a variable called myString. How can I achieve this in JavaS ...

Using asp.net MVC along with jQuery and Razor to toggle checkbox selections within a group

I am attempting to toggle the checkboxes within a group. My goal is to click on the corresponding parent (id=50, id=51), and then have all its child checkboxes also be clicked. I have tried using the closest and find jQuery functions with some modification ...

Implementing user authentication in Rails with Devise and Backbone framework

I am just getting started with backbone.js. Currently, I am working on a rails application utilizing the "backbone-on-rails" gem. After successfully incorporating 3 models and rendering views with backbone, now I am looking to implement authentication usin ...

The dilemma between installing Electron or installing Electron-Builder: which one

When it comes to installing Electron for an Electron app with React, the method can vary depending on the tutorial. Some tutorials use electron-builder while others do not, but there is little explanation as to why. First: npx create-react-app app cd app ...

What is the meaning of a "hook" in the world of HTML?

During a recent interview, a developer asked me about the "hooks" Angular uses with HTML. I admitted that I was not familiar with the term "hook," despite my extensive experience in web development over the past two decades. While I have some ideas of what ...

What could be the reason for the 'tsc' command not functioning in the Git Bash terminal but working perfectly in the command prompt?

I recently installed TypeScript globally on my machine, but I am facing an issue while trying to use it in the git bash terminal. Whenever I run tsc -v, I encounter the following error: C:\Users\itupe\AppData\Roaming\npm/node: l ...

The JavaScript in the Laravel file isn't functioning properly, but it works perfectly when incorporated via CDN

Successfully implemented code: <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script> <script type="text/javascript"> var textWrapper = document.querySelector('.ml6 .letters'); textWrapper.in ...

The issue of passing state in React Router v4 Redirect unresolved

I have a specific private route, /something, that I only want to be accessible when logged in. I've used Redirect with the state parameter set, however, when I try to access it at the destination, location.state is showing as undefined. Here is how I ...