Do not read this Topic if you have not finished Tribute Page (one of the certifications projects) yet! I am sharing solutions to some of the tests!
Hello,
I am making a tribute page, one of the certifications projects.
My code passes the tests but I am not satisfied with the final result; whenever the viewport is narrower than 600px, the <img>
element stops being centered within the parent <figure>
element.
This is the HTML:
<figure id="img-div">
<img id="image" src="https://i.ibb.co/JkVWg7B/Ada-Lovelace-in-1852.jpg"/>
<figcaption id="img-caption">Ada Lovelace in 1852, the year of her death, at the age of 36.</figcaption>
</figure>
and this is the CSS:
figure {
margin: 2em auto;
padding: 2em;
max-width: 80%;
background-color: #f0f0f0;
border-radius: 10px;
}
img {
display: block;
margin: 0 auto;
padding: 1em;
max-width: 100%;
height: auto;
}
figcaption {
font-size: 14px;
}
If the viewport gets below 600px of width there is a bigger padding on the right of the <figure>
element, pushing the <img>
element to the left. Why?