I am trying to create a layout, where I have columns, with dynamic content, I would like to shrink or expand these columns according to the content (much like pInterest).
From what I am seeing online, most of the examples, they have divs, with background color, and they show you how to layout these and show nice designs, but when I tried to do that and add content, I faced this issue.
Any hint is appreciated. Here's my code:
body {
color: #fff;
font-family: 'Nunito Semibold';
text-align: center;
}
#content {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;
max-width: 960px;
margin: 0 auto;
}
#content div {
background: #3bbced;
padding: 30px;
}
#content div:nth-child(even) {
background: #777;
padding: 30px;
}
.nested {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 10px;
/*grid-column: span 3;*/
}
.nested p {
border: 1px solid #fff;
padding: 20px;
margin: 0;
}
<div id="content">
<div>I don't want to stretch that long</div>
<div>me too</div>
<div>3
<p>Image or anything can be here .. Image or anything can be here .. Image or anything can be here .. Image or anything can be here .. Image or anything can be here .. Image or anything can be here .. Image or anything can be here .. Image or anything
can be here .. </p>
</div>
<div class="nested">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
</div>
<div>5</div>
<div>6</div>
</div>