Given a div in a Webpage where I want to display an image and a paragraph right next to it. I want the image to get smaller if the size of the screen is getting smaller and the text to go around it. Thus I made the image float to the left, set the width to 40% and the max-width: 380px. That worked just fine. Now under the paragraph I want to display an image grid of three images.
If the screen is is small enough the grid will be under the paragraph and fill the screen. That is how I want it. But if the screen is eventually getting bigger the grid will be under the text. So far so good. But now I get a blank space under the big image depending on the size of the screen. I want that blank space gone( i.e that the height of the image is the same as the combined height of the paragraph and grid). But I don't seem to get it right.
Here how it looks how it should be on a small screen: small screen
And here is the white space I want to get rid of under the image on a big screen: big screen.
Any tips or solutions would by very appreciated
The code for the page using Kirby:
<?php
$chapter = [
'title' => $data->title(),
'id' => $data
];
?>
<?php snippet('chapter', ['chapter' => $chapter]) ?>
<div id="contractPlusParagraph">
<img src=<?= image('studioSonnenstrasse/Vertrag.jpg')->url() ?> id="contract" class="contract-image">
<div class="content-wrap">
<p>
<?= $data->firstParagraph()->kirbytext() ?>
<p>
<div class="image-grid">
<img src="<?= image('studioSonnenstrasse/emptyRoom/emptyRoom1.jpg')->url() ?>" class="imageSonnenstraße">
<img src="<?= image('studioSonnenstrasse/emptyRoom/emptyRoom2.jpg')->url() ?>" class="imageSonnenstraße">
<img src="<?= image('studioSonnenstrasse/emptyRoom/emptyRoom3.jpg')->url() ?>" class="imageSonnenstraße">
</div>
</div>
</div>
<p>
<?= $data->secondParagraph()->kirbytext() ?>
<p>
<?php endslot() ?>
<?php endsnippet() ?>
The current css:
.contractPlusParagraph{
display:flex;
}
#contract {
width: 40%;
max-width: 380px;
float: left;
margin-right: 20px;
}
.image-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.imageSonnenstraße {
max-width: 100%;
height: auto;
}