Tribute Page - Build a Tribute Page

Tell us what’s happening:

I can’t figure out how to keep my figcaption aligned with image during resize. It’s fine when shrinking but, it doesn’t stay in place when viewport is increased. I’ve been searching for quite awhile and wasn’t able to find an answer. The closest thing I found said to do display: relative: but, that didn’t work. I thought it might be a flexbox thing but, I couldn’t find anything about it. It’s not part of project, however, I would like to know how to do it.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" content="width=device-with, initial-scale=1.0">
    <link rel="stylesheets" href="styles.css">
    <title id="title">Tribute page to Stephen King</title>
    <header><h1>Stephen King</h1>
    <p>Legend of modern day horror</p>
    <main id="main">
        <figure id="img-div">
          <img src="" alt="Stephen King with sinister smile"/ id="skimage" class="skpic">
          <figcaption id="img-caption">source:</figcaption>

/* file: styles.css */
@media (prefers-reduced-motion: no-preference){* {scroll-behavior:smooth;}}
header {text-align:center;width:100%; font-size:25px;font-family:fantasy,impact;background-color:black;color:red}
hr {height:2px; background-color:red; border-color:red;}
.skpic {display:block; margin-left:auto; margin-right:auto;max-width:100%;height:auto;}
figcaption {}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 OPR/

Challenge Information:

Tribute Page - Build a Tribute Page

here are examples of what I mean.

1 Like

hi there!
that is the wrong code. relative value should have the property position.

position: relative;

display needs only block and none value;
position needs absolute, relative, fixed and sticky values.

Thanks for the reply. Unfortunately none of those values accomplish what I’m trying to do. The caption still moves out of line when enlarging the viewport.

Thanks. I finally figured it out. I needed to apply a table value for the display on the figure element and then apply a table-caption value to display in the figcaption as well as set caption-side to bottom.

1 Like

I also applied the margins into the figure which allowed me to remove the class selector for the image ( .skpic).

can you post your updated code if you are having issues still?

I’m no longer having issues. I was able to get it to work and I already completed it and submitted it. I have the txt file if you would like to see it. I hate to admit it but, I spent close to 2 hours trying to find the solution even though it wasn’t a required part of the project. But, I just wasn’t able to let it go. And I had to put .skpic selector back in because the project required things that had to be applied specifically to that.