I am in the process of developing a static website from scratch, coding the HTML and CSS components myself. My goal is to create a responsive "image gallery" that adjusts the width of the images based on the user's screen size. To achieve this, I followed a tutorial provided at CSS Image Gallery - responsive.
However, while customizing it to suit my preferences, I encountered an issue that I couldn't resolve with my current level of HTML/CSS skills (which are still fairly basic as I'm relatively new to this field). The problem arises when I have multiple images of the same size in the gallery, but the captions for these images vary in length. This inconsistency negatively impacts the layout of the text following the gallery. Despite attempting solutions found in various tutorials, none of them have proven effective so far.
Can any of you provide an easy solution to this problem? If yes, kindly explain the adjustments made, as I aim to gain a deeper understanding of the functioning of my website (this is why I refrained from using static site generators).
Note: I have created three types of galleries; one each for two, three, and four images. This explains the use of classes such as ".responsivethree".
https://i.sstatic.net/dF6Ed.png
<!DOCTYPE html>
<html lang="en-NL">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
...