Masonry-Style Layout in CSS
How do I make an masonry-style layout in css?
Masonry's a pretty neat piece of work, but why use all that js?. What is a masonry-style layout in css? How do you make a masonry-style layout in css? This script and codes were developed by Matt Gross on 28 August 2022, Sunday.
Masonry-Style Layout in CSS - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Masonry-Style Layout in CSS</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!-- Section with a bunch of items in it. I'm using images, but in principle this should work with whatever. -->
<section class="container"> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97450&w=350&h=450" alt="" /> </div> <p>And this is some Text, just chucked right in the middle.</p> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97350&w=350&h=350" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97250&w=350&h=250" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97250&w=350&h=250" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=750%C3%971250&w=750&h=1250" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97450&w=350&h=450" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97550&w=350&h=550" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97350&w=350&h=350" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97350&w=350&h=350" alt="" /> </div> <div class="item"> <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97550&w=350&h=550" alt="" /> </div>
</section>
</body>
</html>
Masonry-Style Layout in CSS - Script Codes CSS Codes
/* Basic Reset */
* { margin: 0; padding: 0; box-sizing: border-box;
}
body { padding: 30px;
}
/* Styles for the grid */
.container {
/* Number of columns */ -webkit-column-count: 3; -moz-column-count: 3; column-count: 3;
/* horizontal space between blocks */ -webkit-column-gap: 1px; -moz-column-gap: 1px; column-gap: 1px;
}
.item {
/* Vertical space between items */ margin-bottom: 1px;
/* Keeps the individual blocks of content from breaking, good for mixed content, but not necessary. */ -webkit-column-break-inside: avoid; page-break-inside: avoid; break-inside: avoid;
}
/* Useful styling for the images, keeps them in place & preserves their aspect ratio */
.item img { display: block; width: 100%; height: auto;
}
/* Responsive too! */
@media (max-width: 740px) { .container { -webkit-column-count: 2; -moz-column-count: 2; column-count: 2; }
}
@media (max-width: 520px) { .container { -webkit-column-count: 1; -moz-column-count: 1; column-count: 1; }
}
Developer | Matt Gross |
Username | mattgrosswork |
Uploaded | August 28, 2022 |
Rating | 3 |
Size | 2,116 Kb |
Views | 32,384 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by Matt Gross | 12,421 Kb |
EvenVision Branded Ajax Loader | 3,023 Kb |
Working on a Volusion version of a Drupal Theme | 6,095 Kb |
Footnote concept | 3,056 Kb |
Fullscreen Video Background | 1,706 Kb |
Easy Lines Around a Subtitle | 1,807 Kb |
Site Menu | 6,873 Kb |
Simple Skewed Image Container | 1,676 Kb |
Playing with transition timing | 1,993 Kb |
Super Basic Inline Menu | 1,668 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Price table | Serluk | 5,928 Kb |
A Pen by Alex Edwards | Exards | 8,218 Kb |
Main page display | BarryKe | 4,562 Kb |
A Pen by Huan Nghiem | Nightshade | 10,646 Kb |
Hello People | Danburrows | 2,365 Kb |
Mobile first social buttons with no iframe | Alistairtweedie | 3,158 Kb |
Planet Awesome | Bartuc | 3,554 Kb |
Social.svg.min | Larsenwork | 13,849 Kb |
A Pen by Jay | Jaycode | 3,784 Kb |
SnappySnippet Test | Elmsoftware | 8,385 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!