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

360
Views
How to center a caption and pop up text on an image in html and css

I'm currently trying to code a website for the first time, and have run into the problem that when I'm trying to caption an image in a gallery and add a pop up info slide that it isn't centered under the image, but instead it is to the right of the image. The image should always have a caption, and when you scroll over the image a text box should go up, so that a description could be read. I'm not very sure how to fix the problem since I thought I had already centered the text. If anyone can help me I'll be very grateful.

    <div class="row1">
  <div class="column1">
    <img src="img/hi_bild.jpg" height="200px" width="200px">
    <figcaption> John Smith</figcaption>
    <div class="text">
      <p>This is a cat</p>
      <span class="arrow-link">ARROW IMG HERE</span>
    </div>
  </div>
  <div class="column1">
    <img src="img/hi_bild.jpg" height="200px" width="200px">
    <div class="text">
      <p>This is a cat</p>
    </div>
  </div>
  <div class="column1">
    <img src="img/hi_bild.jpg" height="200px" width="200px">
    <div class="text">
      <p>This is a cat</p>
    </div>
  </div>
</div>

https://jsfiddle.net/b0gdpmjw/

image with caption

image with caption and pop up description

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Position: Absolute; and flexbox structure, will do what you want.

https://www.w3schools.com/css/css3_flexbox.asp https://www.w3schools.com/css/css_positioning.asp

about 4 years ago · Juan Pablo Isaza Report

0

the solution is to specify the position from left for .text.

(tipp: i think it is a good idea to start with bootstrap. with bootstrap you can build up the basic framework of a website relatively easy, so that it also works on the smartphone. afterwards you can customize everything yourself as you like. to build up the basic framework of a website yourself and make it responsive for different devices is very difficult as a beginner. so you run from one big problem into the next. latest when you start with media-queries, you can hardly keep track of it all.)

figcaption {
  color: white;
  font-style: oblique;
  position: relative;
  text-align: center;
}

* {
  box-sizing: border-box;
}

.column1 {
  position: relative;
  width: 200px;
  height: 300px;
  overflow: hidden;
}

p {
  color: black; /* changed to black, so you can see the text */
  font: 25px Sulphur Point, sans-serif;
}

.text {
  position: absolute;
  bottom: 0;
  /* right: 0;*/
  left: 0; /* here */
  width: 200px;
  height: 0;
  text-align: center;
  transition: height 0.7s ease-out;
}

.column1:hover>.text {
  height: 150px;
}

.column1 {
  float: left;
  width: 33.33%;
  padding: 5px;
  margin-bottom: 50px;
}

/* Clearfix (clear floats) */
.row1::after {
  content: "";
  clear: both;
  display: table;
  margin-bottom: 50px;
}
<div class="row1">
  <div class="column1">
    <img src="img/hi_bild.jpg" height="200px" width="200px">
    <figcaption> John Smith</figcaption>
    <div class="text">
      <p>This is a cat</p>
      <span class="arrow-link">ARROW IMG HERE</span>
    </div>
  </div>
  <div class="column1">
    <img src="img/hi_bild.jpg" height="200px" width="200px">
    <div class="text">
      <p>This is a cat</p>
    </div>
  </div>
  <div class="column1">
    <img src="img/hi_bild.jpg" height="200px" width="200px">
    <div class="text">
      <p>This is a cat</p>
    </div>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza 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!