How to render the item horizontally (Masonry Layout )?
I end up with a package solution and it works perfectly fine!
DaPotatoMan/vue-next-masonry
and this is how it looks like
<masonry
:cols="{ default: 4, 1024: 3, 768: 2, 640: 1 }"
:gutter="{ default: 40, 1024: 30, 768: 20 }"
>
<div v-for="(post, index) in posts.data" :key="index" class="mb-10">
<ExploreCard
v-for="(post, index) in posts.data"
:key="index"
:post="post"
:canLike="this.canLike"
/>
</div>
</masonry>
In this way, all the post is rendered in horizontal order !
Remove spaces caused by grid rows by using elements with variable heights
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>
How to create masonry layout using css only?
You can use flexbox. See codepen for example, and complete guide to flex box to learn more.
In order to keep the layout horizontal, adjust the flex-direction
to your liking.
Related Topics
Best Way to Create Video from Html5 Animation
Large File Upload Though HTML Form (More Than 2 Gb)
Bootstrap Accordion Issue With Arrow
How to Automatically Set Text Box to Uppercase
Children Not Staying Inside Parent Divs
100Vh Height When Address Bar Is Shown - Chrome Mobile
How to Prevent a User from Entering Negative Values in HTML Input
How to Divide Div Color With 30% Different Color and 70% Different Color in Vertical Using CSS
Htmlspecialchars() Expects Parameter 1 to Be String Array Given
Angular: Using the Ternary Operator in HTML Template
Navbar Menu Dropdown Not Working (Won't Drop Down When Clicked)
How to Switch Two Divs in HTML
Angular: *Ngif Tag on Input Element Causes It to Be Undefined. Cannot Read Value from Input Field
A Div With Auto Resize When Changing Window Width\Height
How to Get the Client Ip Address from Browser in Angular (Typescript)
Floated Elements of Variable Height Push Siblings Down
What Are the Default Margins For the HTML Heading Tags (≪H1≫, ≪H2≫, ≪H3≫, etc.)