Sticky grid column when scrolling up and down - html

I have a grid layout with two columns. These columns will be different heights and have a height greater than the viewport. This means that if column 1 has a height greater than column 2, then when we scroll down, we will see some whitespace in column 2. In this case, I am trying to make column2 sticky so that there is no wasted whitespace when scrolling.
When scrolling down: When the bottom of the content in column 2 is reached before column 1, column 2 should stick until the bottom of column 1 is reached.
When scrolling up: When the top of column 2 is reached before column 1, column 2 should stick until the top of the other is reached.
I can get the scrolling down to work but once we've reached the bottom and start scrolling up, column 2 will stay stuck to the bottom. It should start scrolling up.
.grid {
display: grid;
grid-template-columns: 200px 200px;
}
.content1 {
height: 2000px;
background: linear-gradient(red, blue);
}
.content2Container {
display: flex;
flex-direction: column;
}
.content2 {
height: 1000px;
border: solid 2px blue;
position: sticky;
bottom: 0px;
}
.flex {
display: flex;
flex-grow: 1;
}
<div class="grid">
<div class="content1"></div>
<div class="content2Container">
<div class="flex"></div>
<div class="content2">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut varius enim, commodo vehicula diam. Ut sagittis eu dolor ac tristique. Ut porta interdum magna non semper. Mauris a consequat quam, in rutrum diam. In felis enim, condimentum in ullamcorper
ut, aliquam sed velit. Nunc pretium ante vel massa vestibulum vulputate. Pellentesque ex mauris, lacinia in ligula at, pellentesque tempor est. Nam efficitur nunc erat, ut ultrices diam euismod ege Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Quisque ut varius enim, commodo vehicula diam. Ut sagittis eu dolor ac tristique. Ut porta interdum magna non semper. Mauris a consequat quam, in rutrum diam. In felis enim, condimentum in ullamcorper ut, aliquam sed velit. Nunc pretium ante
vel massa vestibulum vulputate. Pellentesque ex mauris, lacinia in ligula at, pellentesque tempor est. Nam efficitur nunc erat, ut ultrices diam euismod ege Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut varius enim, commodo
vehicula diam. Ut sagittis eu dolor ac tristique. Ut porta interdum magna non semper. Mauris a consequat quam, in rutrum diam. In felis enim, condimentum in ullamcorper ut, aliquam sed velit. Nunc pretium ante vel massa vestibulum vulputate. Pellentesque
ex mauris, lacinia in ligula at, pellentesque tempor est. Nam efficitur nunc erat, ut ultrices diam euismod ege
</div>
</div>
</div>
dummy code to stop jsfiddle warning
Here is my jsfiddle https://jsfiddle.net/mattyBraps/mwa0cv2g/35/

Related

How can I allow an image inside of a column to extend to the edge of the viewport?

I have two 50% width columns that exist in a Bootstrap container. The left column contains some text, and the right column contains some text and an image. I'd like to allow the image to break out of the column and container and extend to the right edge of the viewport. Here is my starting template:
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-6">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut etiam sit amet nisl. Congue eu consequat ac felis. Ullamcorper malesuada proin libero nunc consequat interdum varius sit amet. Sed viverra ipsum nunc aliquet bibendum enim facilisis. Commodo ullamcorper a lacus vestibulum sed arcu. Tristique et egestas quis ipsum suspendisse ultrices gravida. Sollicitudin ac orci phasellus egestas tellus. Accumsan in nisl nisi scelerisque. Eros donec ac odio tempor orci. Tincidunt eget nullam non nisi est sit amet. Mauris pellentesque pulvinar pellentesque habitant. Odio tempor orci dapibus ultrices in iaculis nunc sed augue. Faucibus purus in massa tempor nec feugiat. Cras semper auctor neque vitae tempus quam. Viverra nibh cras pulvinar mattis nunc sed blandit libero. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque.</p>
</div>
<div class="col-sm-6">
<p>Odio tempor orci dapibus ultrices in iaculis nunc sed augue. Faucibus purus in massa tempor nec feugiat. Cras semper auctor neque vitae tempus quam. Viverra nibh cras pulvinar mattis nunc sed blandit libero. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque.</p>
<img src="https://developers.elementor.com/docs/assets/img/elementor-placeholder-image.png" alt="" class="img-fluid" />
</div>
</div>
</div>
My goal is to allow the image to scale outwards towards the right to the edge of the viewport, but I want the text above it remain within the bounds of the column.
I'd like to avoid using absolute positioning if possible. I was looking at this technique to break an image out of a container and make it the full width of the page, but couldn't figure out how to adapt it for a half width column.
The closest I've gotten is just setting the width by figuring out the space from the edge of a column to the edge of the viewport + 100% of the image:
#media (min-width: 576px) {
img.img-fluid {
max-width: none;
width: calc(100% + (100vw - 540px) / 2);
}
}
#media (min-width: 768px) {
img.img-fluid {
max-width: none;
width: calc(100% + (100vw - 720px) / 2);
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-6">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut etiam sit amet nisl. Congue eu consequat ac felis. Ullamcorper malesuada proin libero nunc consequat interdum varius sit amet. Sed viverra ipsum nunc aliquet bibendum enim facilisis. Commodo ullamcorper a lacus vestibulum sed arcu. Tristique et egestas quis ipsum suspendisse ultrices gravida. Sollicitudin ac orci phasellus egestas tellus. Accumsan in nisl nisi scelerisque. Eros donec ac odio tempor orci. Tincidunt eget nullam non nisi est sit amet. Mauris pellentesque pulvinar pellentesque habitant. Odio tempor orci dapibus ultrices in iaculis nunc sed augue. Faucibus purus in massa tempor nec feugiat. Cras semper auctor neque vitae tempus quam. Viverra nibh cras pulvinar mattis nunc sed blandit libero. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque.</p>
</div>
<div class="col-sm-6">
<p>Odio tempor orci dapibus ultrices in iaculis nunc sed augue. Faucibus purus in massa tempor nec feugiat. Cras semper auctor neque vitae tempus quam. Viverra nibh cras pulvinar mattis nunc sed blandit libero. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque.</p>
<img src="https://developers.elementor.com/docs/assets/img/elementor-placeholder-image.png" alt="" class="img-fluid" />
</div>
</div>
</div>
This seems really close by there's always a tiny bit of space left and I'm not sure why. I've tried accounting for the gutter/padding of 12px on the columns but then it overflows.

Two column layout - content one colulmn centered but the other column top aligned to the top of the centered content

I'm looking for a way to create this two column layout, the content on the right is centred horizontally and vertically but the content on the left is centred horizontally and vertically aligned with the top of the content in column twos as the length of the content in column two changes the content in column one always stays aligned to the top.
Please take a look at the image attached as this is easier to explain visually
This can't just be a padded box because as the content on the right grows the padding reduces to stay centered, and the main columns need to stay a min height
Updated layout image
Based on Кольо Пеев answer below I've modified my codepen
https://codepen.io/nitrokev/pen/RwMQZeJ
<div class="fifty-fifty-project-details-grid">
<article class="fifty-fifty-content left lightblue">
<div class="entry-content" >
<h3>Content 1</h3>
</div>
</article>
<article class="fifty-fifty-content right" >
<div class="entry-content" >
<h3>Content 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In enim lorem, sollicitudin ut accumsan in, porta sed dui. Sed sagittis est risus, ac luctus odio porta at. Vivamus at nibh et mi euismod sagittis et sed justo. Nulla pretium pellentesque eros, vel aliquam elit egestas eu. Aliquam erat lorem, tristique sit amet est eu, elementum porta augue. Morbi consequat magna felis, placerat convallis nisl placerat a. Nullam porttitor suscipit metus a condimentum. Nunc eleifend ex sed tristique tempus. Nunc elementum ligula nec pulvinar mattis. Aenean tincidunt, odio in congue iaculis, ipsum quam hendrerit velit, id commodo mauris ante rhoncus odio. Sed eget nibh vitae ipsum consectetur porta sit amet eget ante. Donec ultricies lacinia ultricies. Nullam id porttitor leo. Quisque sit amet nisl ultrices sapien aliquet gravida. Nam auctor mi ut orci dictum, sit amet tempor metus eleifend. Donec rhoncus et justo ac sollicitudin. </p>
</div>
</article>
</div>
.fifty-fifty-project-details-grid {
display: flex;
flex-flow: row wrap;
overflow: hidden;
min-height:45rem;
}
.fifty-fifty-content {
display: flex;
flex-flow: row wrap;
align-items: center;
flex: 0 0 auto;
width: 50%;
margin-left: 0;
margin-right: 0;
height: auto;
padding:3rem;
}
.left{
background-color:#52AACB;
}
.right{
background-color:#52CB8F;
}
I think if there was a way to calculate the current height of the content in column two and apply it to column one, that might work?
Try running this code snippet. I am not fully aware of what you expect since there is no real content given anywhere from your side, but maybe with a few more lines of CSS you can achieve what you desire.
.container {
min-height: 400px;
background-color: #52CB8F;
display: grid;
}
.container__parent {
display: grid;
grid-template-columns: 1fr 1fr;
align-self: center;
}
.container__child {
padding: 16px;
background-color: #555;
text-align: center;
color: #fff;
}
.container__child:first-child {
border: 1px solid red;
}
.container__child:last-child {
border: 1px solid blue;
}
<div class="container">
<div class="container__parent">
<div class="container__child">
test string
</div>
<div class="container__child">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Facilisis mauris sit amet massa vitae tortor condimentum lacinia quis. Aliquet enim tortor at auctor. Facilisi etiam dignissim diam quis enim lobortis. Eget nulla facilisi etiam dignissim diam quis enim. Amet nisl suscipit adipiscing bibendum est ultricies integer. Id aliquet lectus proin nibh. Interdum consectetur libero id faucibus. Ornare lectus sit amet est placerat in egestas erat imperdiet. Felis imperdiet proin fermentum leo vel. Arcu dui vivamus arcu felis bibendum ut. Amet luctus venenatis lectus magna fringilla urna. Lobortis elementum nibh tellus molestie. Nibh praesent tristique magna sit amet purus gravida. Odio facilisis mauris sit amet massa vitae. Vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus. Orci phasellus egestas tellus rutrum.
</div>
</div>
</div>

Dont Indent First Line of First Paragraph using CSS

How would I prevent the line indent for the first paragraph in a section?
This is very common for many academic formats.
Sample Output
Introduction
For the first paragraph in the section, there is no indent: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. In eu mi bibendum neque egestas congue. A arcu cursus vitae congue mauris rhoncus aenean vel elit.
For all following paragraphs, there is an indent set by text-indent: Sed velit dignissim sodales ut. Nunc pulvinar sapien et ligula ullamcorper malesuada proin libero. Tristique et egestas quis ipsum suspendisse ultrices gravida dictum. Augue mauris augue neque gravida in fermentum et sollicitudin ac.
For all following paragraphs, there is an indent set by text-indent: Nunc sed id semper risus in hendrerit. Etiam non quam lacus suspendisse faucibus interdum posuere lorem. Ut porttitor leo a diam sollicitudin tempor id. Facilisis mauris sit amet massa vitae tortor condimentum lacinia quis. Sagittis vitae et leo duis ut.
Right now, I have the following code in my CSS
p {
text-indent: 50px;
}
You may want to use the css pseudo-class 'first-of-type'
p:first-of-type {
text-indent: 0;
}
As the css selector implies the styling will only apply to the first p element.
You can use CSS Adjacent sibling combinator like this:
p + p {
text-indent: 50px;
}
Run the code to see the result
p + p {
text-indent: 50px;
}
<h1>Introduction</h1>
<p>For the first paragraph in the section, there is no indent: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. In eu mi bibendum neque egestas congue. A arcu cursus vitae congue mauris rhoncus aenean vel elit.</p>
<p>For all following paragraphs, there is an indent set by text-indent: Sed velit dignissim sodales ut. Nunc pulvinar sapien et ligula ullamcorper malesuada proin libero. Tristique et egestas quis ipsum suspendisse ultrices gravida dictum. Augue mauris augue neque gravida in fermentum et sollicitudin ac.</p>
<p>For all following paragraphs, there is an indent set by text-indent: Nunc sed id semper risus in hendrerit. Etiam non quam lacus suspendisse faucibus interdum posuere lorem. Ut porttitor leo a diam sollicitudin tempor id. Facilisis mauris sit amet massa vitae tortor condimentum lacinia quis. Sagittis vitae et leo duis ut.</p>
You are correct, don't indent the first line of the first paragraph. To attract the eye, use an initial cap (increases readership around 15%).
However, in best-practices typography, you should only use one or the other: 1) a space between paragraphs (not a whole space, mind you) and no indent
OR 2) no space between paragraphs and but indent the first line.
* {
margin: 0;
padding: 0;
}
h3 {
font-family: Georgia;
font-size: 1.5rem;
line-height: 1.3rem;
font-weight: normal;
margin: 2.0rem 0;
}
p {
font-family: Georgia;
font-size: 1.0rem;
line-height: 1.3rem;
}
.space-noindent p {
margin-bottom: 0.8rem;
}
.nospace-indent p:nth-child(1n+2) {
text-indent: 1.5rem;
}
.space-noindent p:nth-of-type(1):first-letter{
font-size: 2.5rem;
}
<div class="space-noindent">
<h3>Space, no indent:</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt imperdiet justo, ac rhoncus urna sollicitudin vitae. Duis eu dolor eu dui tempor cursus. Phasellus sit amet velit sit amet metus accumsan rhoncus. Maecenas et est odio, id tincidunt ligula. Donec sapien diam, vestibulum ac cursus eget, dignissim vel diam. Praesent interdum vestibulum erat nec volutpat.</p>
<p>Suspendisse interdum congue sagittis. Suspendisse tortor ligula, facilisis nec molestie vel, laoreet sed diam. Integer libero orci, iaculis dapibus adipiscing sed, varius ut dui. Nullam posuere commodo quam eget ultricies. Duis luctus, mauris at iaculis tempor, ipsum elit auctor neque.</p>
<p>Duis eu dolor eu dui tempor cursus. Phasellus sit amet velit sit amet metus accumsan rhoncus. Maecenas et est odio, id tincidunt ligula. Donec iaculis dapibus adipiscing sed sapien diam, vestibulum ac cursus ege.</p>
</div>
<h3>No space, indent:</h3>
<div class="nospace-indent">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt imperdiet justo, ac rhoncus urna sollicitudin vitae. Duis eu dolor eu dui tempor cursus. Phasellus sit amet velit sit amet metus accumsan rhoncus. Maecenas et est odio, id tincidunt ligula. Donec sapien diam, vestibulum ac cursus eget, dignissim vel diam. Praesent interdum vestibulum erat nec volutpat.</p>
<p>Suspendisse interdum congue sagittis. Suspendisse tortor ligula, facilisis nec molestie vel, laoreet sed diam. Integer libero orci, iaculis dapibus adipiscing sed, varius ut dui. Nullam posuere commodo quam eget ultricies. Duis luctus, mauris at iaculis tempor, ipsum elit auctor neque.</p>
<p>Duis eu dolor eu dui tempor cursus. Phasellus sit amet velit sit amet metus accumsan rhoncus. Maecenas et est odio, id tincidunt ligula. Donec iaculis dapibus adipiscing sed sapien diam, vestibulum ac cursus ege.</p>
</div>

Set row height to fit content height in CSS Grid

I have a grid with two columns and two rows. I have to place two grid items in one column (on the right) and one item on the left. Then I want first element from the right column to have maximum height equal to its content height. How can I accomplish this?
The problem that I'm facing right now is that these two items on the right, have 50% height and I can't find a way to to set first one to minimum possible height, and the other one to the rest of height (auto).
Just to clarify - height of each items is not fixed. Below you can see how it look right now.
One more thing, I can't change order of HTML DIV elements due to responsive web design.
.grid{
display: grid;
grid-template-columns: auto 300px;
grid-column-gap: 20px;
grid-template-areas: "main_content top" "main_content bottom";
}
.left{
grid-area: main_content;
}
.top_right{
grid-area: top;
background: #ffa4a4;
}
.bottom_right{
grid-area: bottom;
background: #c7ffae;
}
<div class="grid">
<div class="top_right">I'm top right</div>
<div class="left">Long left content... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras semper, eros ut cursus semper, dolor felis gravida ligula, et venenatis neque felis quis justo. Duis aliquet ex vitae tincidunt sodales. Fusce neque metus, pharetra eu molestie sed, tincidunt ac eros. Ut vehicula maximus sodales. Curabitur vehicula sollicitudin erat et rutrum. Aliquam id fermentum erat. Nulla pulvinar vel tortor in imperdiet. Nulla sit amet condimentum eros. Vestibulum tempor et massa eu sagittis. Integer eget nisi sagittis, placerat nibh sed, varius mi. Donec vel lorem at dolor euismod porttitor. Curabitur tincidunt magna facilisis, dapibus odio vitae, pretium orci. Aliquam lacus velit, rhoncus non porta vitae, pellentesque at libero. </div>
<div class="bottom_right">I'm bottom right</div>
</div>
You just need to set the first row to auto (content height) and the second row to 1fr (consume remaining space).
.grid{
display: grid;
grid-template-rows: auto 1fr; /* NEW */
grid-template-columns: auto 300px;
grid-column-gap: 20px;
grid-template-areas: "main_content top" "main_content bottom";
}
.left{
grid-area: main_content;
}
.top_right{
grid-area: top;
background: #ffa4a4;
}
.bottom_right{
grid-area: bottom;
background: #c7ffae;
}
<div class="grid">
<div class="top_right">I'm top right</div>
<div class="left">Long left content... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras semper, eros ut cursus semper, dolor felis gravida ligula, et venenatis neque felis quis justo. Duis aliquet ex vitae tincidunt sodales. Fusce neque metus, pharetra eu molestie sed, tincidunt ac eros. Ut vehicula maximus sodales. Curabitur vehicula sollicitudin erat et rutrum. Aliquam id fermentum erat. Nulla pulvinar vel tortor in imperdiet. Nulla sit amet condimentum eros. Vestibulum tempor et massa eu sagittis. Integer eget nisi sagittis, placerat nibh sed, varius mi. Donec vel lorem at dolor euismod porttitor. Curabitur tincidunt magna facilisis, dapibus odio vitae, pretium orci. Aliquam lacus velit, rhoncus non porta vitae, pellentesque at libero. </div>
<div class="bottom_right">I'm bottom right</div>
</div>
You can use height: fit-content to ensure that the element matches the height of the content contained within... though note that the second box will still retain its original position:
.grid{
display: grid;
grid-template-columns: auto 300px;
grid-column-gap: 20px;
grid-template-areas: "main_content top" "main_content bottom";
}
.left{
grid-area: main_content;
}
.top_right{
grid-area: top;
background: #ffa4a4;
height: fit-content;
}
.bottom_right{
grid-area: bottom;
background: #c7ffae;
}
<div class="grid">
<div class="top_right">I'm top right</div>
<div class="left">Long left content... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras semper, eros ut cursus semper, dolor felis gravida ligula, et venenatis neque felis quis justo. Duis aliquet ex vitae tincidunt sodales. Fusce neque metus, pharetra eu molestie sed, tincidunt ac eros. Ut vehicula maximus sodales. Curabitur vehicula sollicitudin erat et rutrum. Aliquam id fermentum erat. Nulla pulvinar vel tortor in imperdiet. Nulla sit amet condimentum eros. Vestibulum tempor et massa eu sagittis. Integer eget nisi sagittis, placerat nibh sed, varius mi. Donec vel lorem at dolor euismod porttitor. Curabitur tincidunt magna facilisis, dapibus odio vitae, pretium orci. Aliquam lacus velit, rhoncus non porta vitae, pellentesque at libero. </div>
<div class="bottom_right">I'm bottom right</div>
</div>
While I'm not sure how to have the second box jump up to match the first with the Grid layout, the desired effect would be quite simple to achieve if you're willing to use flexbox.
Simply add display: flex to .grid, and create a new .right to contain .top_right and .bottom_right. Then optionally flex: 1 to both .left and .right:
.grid {
display: flex;
}
.left {
flex: 1;
}
.right {
flex: 1;
background: #c7ffae;
}
.top_right {
background: #ffa4a4;
height: fit-content;
}
<div class="grid">
<div class="left">Long left content... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras semper, eros ut cursus semper, dolor felis gravida ligula, et venenatis neque felis quis justo. Duis aliquet ex vitae tincidunt sodales. Fusce neque metus, pharetra eu
molestie sed, tincidunt ac eros. Ut vehicula maximus sodales. Curabitur vehicula sollicitudin erat et rutrum. Aliquam id fermentum erat. Nulla pulvinar vel tortor in imperdiet. Nulla sit amet condimentum eros. Vestibulum tempor et massa eu sagittis.
Integer eget nisi sagittis, placerat nibh sed, varius mi. Donec vel lorem at dolor euismod porttitor. Curabitur tincidunt magna facilisis, dapibus odio vitae, pretium orci. Aliquam lacus velit, rhoncus non porta vitae, pellentesque at libero.</div>
<div class="right">
<div class="top_right">I'm top right</div>
<div class="bottom_right">I'm bottom right</div>
</div>
</div>
Note that you'll also need to move the green background from .bottom_right to .right in order for it to stretch the whole height.
This will work across all major browsers.
Hope this helps! :)

Arranage masonry tiles from left to right instead of top to bottom

I'm working on a masonry layout for an upcoming project and would like to know if their is a way to arrange the masonry tiles from left to right instead of top to bottom with only CSS.
I tried recreating the layout on jsfiddle but the output looks different so i decided to take a screenshot instead
http://i255.photobucket.com/albums/hh140/testament1234/Masonry_zps8b8519b6.jpg
HTML
<div class="masonry">
<div class="masonry-columns">
<h2>1st Masonry</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eget fringilla ante. Phasellus tincidunt erat eu sodales semper. Donec sed lorem ut dui lobortis feugiat non at metus. Sed volutpat tortor vitae purus cursus, ut vehicula orci hendrerit. In ac metus ut massa fringilla porttitor. Aenean vitae sapien rutrum, rutrum enim varius, elementum magna. Aliquam sollicitudin accumsan dui, ut faucibus tellus pretium fermentum. In fringilla quam lorem, eget congue dolor euismod at. Proin nunc lorem, rutrum eu rutrum ac, tristique convallis turpis. Fusce faucibus erat a mauris consequat, sed cursus velit aliquet.
</div>
<div class="masonry-columns">
<h2>2nd Masonry</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eget fringilla ante. Phasellus tincidunt erat eu sodales semper. Donec sed lorem ut dui lobortis feugiat non at metus. Sed volutpat tortor vitae purus cursus, ut vehicula orci hendrerit. In ac metus ut massa fringilla
</div>
<div class="masonry-columns">
<h2>3rd Masonry</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eget fringilla ante. Phasellus tincidunt erat eu sodales semper. Donec sed lorem ut dui lobortis feugiat non at metus. Sed volutpat tortor vitae purus cursus, ut vehicula orci hendrerit. In ac metus ut massa fringilla. lorem ut dui lobortis feugiat non at metus. Sed volutpat tortor vitae purus cursus, ut vehicula orci hendrerit. In ac metus ut
</div>
<div class="masonry-columns">
<h2>4th Masonry</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eget fringilla ante. Phasellus tincidunt erat eu sodales semper. Donec sed lorem ut dui lobortis feugiat non at metus. Sed volutpat tortor vitae purus cursus, ut vehicula orci hendrerit. In ac metus ut massa fringilla. lorem ut dui lobortis feugiat non at metus. Sed volutpat tortor vitae purus cursus, ut vehicula orci hendrerit. In ac metus ut massa fringilla porttitor. Aenean vitae sapien rutrum, rutrum enim varius, elementum magna.
</div>
</div>
CSS
html, body{height:100%}
.masonry{
clear: both;
margin: 0px auto;
padding: 20px 20px 0px;
position: relative;
width: 900px;
z-index: 9;
background-color:salmon;
-moz-column-count: 3;
-moz-column-gap: 10px;
-moz-box-sizing:border-box;
height:100%;
}
.masonry-columns{
display: inline-block;
list-style: none outside none;
margin-bottom: 20px;
padding: 20px;
width: 100%;
-moz-box-sizing:border-box;
background-color:teal;
float:left;
direction:ltr
}