Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Why can't I get these images with titles to flow horizontally center?

Previously I posed a question here1, and it was answered appropriately to solve my first issue but not my second issue - the first being proper code arrangement and the second being the question I'm talking about. I removed the CSS code that was originally applied, which you can view on original question, and applied the new CSS code as follows:

.img {
  margin: 10px;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  /* max-width: 800px; */
}
  
.grid a {
  display: flex;
  align-items: center;
}

I removed the max-width: 800px; and received the following resultMinimized screen viewFull Screen View.

Adding the max-width: 800px; showed the same results in image. Tried various combinations of CSS with no positive results. The code snippet as follows:

<div className={styles.grid}>
          <div className={styles.imgc}>
          <a href="..\pages\satweather.js">
            <img
              className={styles.img}
              src="weatherbutton.jpg"
              width="100"
              height="50"
              onclick="openModal();currentSlide(1)"> 
            </img>
            <div>&rarr; SatWeather</div>
          </a>
          </div>

/* code continues in repetition for 4 more images 
before ending with */

</div>

Does anyone have any suggestions on what I might try or a solution to this problem? To get these images aligned center and horizontally to the page. Help is appreciated.

Here is desired result, but without space between photo and link to page desired result

Please Note: This is JS, not HTML.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

  • Here is html version of your code.
  • Use display:flex to image container and then, Make one separate element for image box just like here which is image-box set it's anchor tag to display:flex and align-items:center.

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.container {
  background-color: #050505;
}

.image-container {
  position: relative;
  display: flex;
  flex-direction: row;
  gap: 15px;
  flex-wrap: wrap;
}

.image-class {
  height: 50px;
  width: 100%;
  object-fit: cover;
}

.image-box a {
  display: flex;
  flex-direction:column;
}
<div class="container">
  <div class="image-container">
    <div class="image-box">
      <a href="javasctipt:void(0);">
        <img src="https://source.unsplash.com/random" alt="image" class="image-class">
        <h1>image titel</h1>
      </a>
    </div>
    <div class="image-box">
      <a href="javasctipt:void(0);">
        <img src="https://source.unsplash.com/random" alt="image" class="image-class">
        <h1>image titel</h1>
      </a>
    </div>
    <div class="image-box">
      <a href="javasctipt:void(0);">
        <img src="https://source.unsplash.com/random" alt="image" class="image-class">
        <h1>image titel</h1>
      </a>
    </div>
    <div class="image-box">
      <a href="javasctipt:void(0);">
        <img src="https://source.unsplash.com/random" alt="image" class="image-class">
        <h1>image titel</h1>
      </a>
    </div>
  </div>
</div>

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!