0

This is the basic layout of the page:

* {
  margin: 0;
  padding: 0;
}

img {
  width: 100%;
  float: left;
}

#grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

#test-one {
  grid-column-start: 1;
  grid-column-end: 2;
  width: 100%;
  height: 300px;
}

#test-two {
  grid-column-start: 2;
  grid-column-end: 3;
  width: 100%;
}

#test-three {
  grid-column-start: 2;
  grid-column-end: 3;
  width: 100%;
}
<div id="grid">
  <div id="test-one"><img src="https://upload.wikimedia.org/wikipedia/commons/9/97/Feral_cat_Virginia_crop.jpg"></div>
  <div id="test-two">
    <h2> Hello </h2>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna.</div>
  <div id="test-three">
    <h2>Please no gap to top text with the "Hello" headline</h2>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
    dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </div>
</div>

The image will have a specific height. The text areas have a dynamic height based on the text. Between the text blocks with the IDs #test-two and #test-three shouldn't be a vertical gap. Can this be fixed with a few CSS settings? Or does the layout need to be reorganzied?

Addition: I think working with grid-row settings doesn't help here much since the heights are variable. Let me know if I am wrong.

Anna_B
  • 820
  • 1
  • 4
  • 23
  • You can either span `.test-one` through 2 rows (see grid-row: xx;) in your favorite grid tutorial) , take a look at masonry grid (here in the search) or even use column CSS if that's fine for you. – G-Cyrillus Apr 22 '22 at 19:35
  • Hey, thank you! What do you mean with "use column CSS"? – Anna_B Apr 22 '22 at 19:59
  • I added more duplicate, check the last one – Temani Afif Apr 22 '22 at 20:07
  • @TemaniAfif Thank you. I just checked the other recommendations. Maybe I am wrong, but I think these are totally different issues. So if I try to copy for example some stuff from the last one, then this results: https://jsfiddle.net/7vaLj39g/2/ – And I don't need it turned around, I just want to remove the space – Anna_B Apr 22 '22 at 20:17
  • they are exactly the same issues, and the third duplicate provides a clear answer: https://jsfiddle.net/fm3osdpw/ ... you just need to be patient to understand the duplicates, the code and trying and please stop re-asking the same question .. it will *always* get closed. Edit and vote to reopen – Temani Afif Apr 22 '22 at 21:05

1 Answers1

0

from my comment

You can either span .test-one through 2 rows (see grid-row: xx;) in your favorite grid tutorial) , take a look at masonry grid (here in the search) or even use column CSS if that's fine for you. – G-Cyrillus 1 min

here an example via grid-row-start/end like you did for column :

#grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column-gap: 10px;
}

#test-one {
  grid-column-start: 1;
  grid-column-end: 2;
  background-color: red;
  grid-row-start: 1;
  grid-row-end:3;
  height: 100px;
  width: 100%;
}

#test-two {
  grid-column-start: 2;
  grid-column-end: 3;
  background-color: blue;
  height: 50px;
  width: 100%;
}

#test-three {
  grid-column-start: 2;
  grid-column-end: 3;
  background-color: green;
  height: 50px;
  width: 100%;
}
<div id="grid">
  <div id="test-one">Hello Box</div>
  <div id="test-two">Hey Box</div>
  <div id="test-three">Please no top gap to the "Hey Box"</div>
</div>
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
  • Hey, sorry. I needed to update my question. I wanted to post a new one, but it got directly closed. – Anna_B Apr 22 '22 at 19:58
  • @Anna_B don't be sorry, some question/issues are redondant and can link to many duplicates. It happens, do not hesitate to ask again if something peticular is still an issue for you ;) A clear Description of your issue might lead to another duplicate, else answered with specific explanation. Lots of us are around once in a while – G-Cyrillus Apr 22 '22 at 20:09