Responsive Grid Proportion
How do I make an responsive grid proportion?
Keeping the proportion of elements with fluid height.. What is a responsive grid proportion? How do you make a responsive grid proportion? This script and codes were developed by Renato Ribeiro on 17 November 2022, Thursday.
Responsive Grid Proportion - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Responsive Grid Proportion</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ /* COMPONENT */
.grid { font-size: 0; /* inline white-space */
}
.grid > div { width: 20%; position: relative; display: inline-block; font-size: 14px; /* normalize font-size */
}
@media (max-width: 1050px) { .grid > div { width: 25%; }
}
@media (max-width: 800px) { .grid > div { width: 33.33%; }
}
@media (max-width: 550px) { .grid > div { width: 50%; }
}
@media (max-width: 300px) { .grid > div { width: 100%; }
}
.grid > div > img.square { width: 100%;
}
.grid > div > .content { position: absolute; height: 100%; width: 100%; background: white; color: black; top: 0; left: 0; padding: 20px;
}
/* EXAMPLE STYLES */
body, html { height: 100%; padding: 0; margin: 0; font-smoothing: antialiased; background: #ecf0f1;
}
body { font-family: 'Roboto';
}
*, *:before, *:after { box-sizing: border-box;
}
h1 { text-align: center; color: #2c3e50; font-size: 50px; line-height: 0.8em;
}
h1 small { font-size: 0.5em; color: #e74c3c;
}
@media (max-width: 500px) { h1 { font-size: 35px; }
}
@media (max-width: 300px) { h1 { font-size: 25px; }
}
.grid > div > .content { border: 5px solid #ecf0f1; background: white; color: #888888;
}
.top { width: 100%; height: 4px; background: #2ecc71; position: relative;
}
.top:before,
.top:after { content: ''; display: block; width: 33.33%; height: 4px; position: absolute; top: 0;
}
.top:before { left: 0; background: #9b59b6;
}
.top:after { right: 0; background: #e67e22;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<div class="top"></div>
<h1> Responsive Grid <br /> <small>Keeping the proportion of elements</small>
</h1>
<div class="grid"> <div> <img class="square" src="http://placehold.it/1x1"/> <div class="content"> <h2>Content</h2> <p>Lorem ipsum dolor sit amet</p> </div> </div> <div> <img class="square" src="http://placehold.it/1x1"/> <div class="content"> <h2>Content</h2> <p>Lorem ipsum dolor sit amet</p> </div> </div> <div> <img class="square" src="http://placehold.it/1x1"/> <div class="content"> <h2>Content</h2> <p>Lorem ipsum dolor sit amet</p> </div> </div> <div> <img class="square" src="http://placehold.it/1x1"/> <div class="content"> <h2>Content</h2> <p>Lorem ipsum dolor sit amet</p> </div> </div> <div> <img class="square" src="http://placehold.it/1x1"/> <div class="content"> <h2>Content</h2> <p>Lorem ipsum dolor sit amet</p> </div> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Responsive Grid Proportion - Script Codes CSS Codes
/* COMPONENT */
.grid { font-size: 0; /* inline white-space */
}
.grid > div { width: 20%; position: relative; display: inline-block; font-size: 14px; /* normalize font-size */
}
@media (max-width: 1050px) { .grid > div { width: 25%; }
}
@media (max-width: 800px) { .grid > div { width: 33.33%; }
}
@media (max-width: 550px) { .grid > div { width: 50%; }
}
@media (max-width: 300px) { .grid > div { width: 100%; }
}
.grid > div > img.square { width: 100%;
}
.grid > div > .content { position: absolute; height: 100%; width: 100%; background: white; color: black; top: 0; left: 0; padding: 20px;
}
/* EXAMPLE STYLES */
body, html { height: 100%; padding: 0; margin: 0; font-smoothing: antialiased; background: #ecf0f1;
}
body { font-family: 'Roboto';
}
*, *:before, *:after { box-sizing: border-box;
}
h1 { text-align: center; color: #2c3e50; font-size: 50px; line-height: 0.8em;
}
h1 small { font-size: 0.5em; color: #e74c3c;
}
@media (max-width: 500px) { h1 { font-size: 35px; }
}
@media (max-width: 300px) { h1 { font-size: 25px; }
}
.grid > div > .content { border: 5px solid #ecf0f1; background: white; color: #888888;
}
.top { width: 100%; height: 4px; background: #2ecc71; position: relative;
}
.top:before,
.top:after { content: ''; display: block; width: 33.33%; height: 4px; position: absolute; top: 0;
}
.top:before { left: 0; background: #9b59b6;
}
.top:after { right: 0; background: #e67e22;
}
Responsive Grid Proportion - Script Codes JS Codes
/**
Renato Ribeiro <[email protected]>
http://rena.to/
**/
Developer | Renato Ribeiro |
Username | renatorib |
Uploaded | November 17, 2022 |
Rating | 3 |
Size | 3,608 Kb |
Views | 18,216 |
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 |
Animate.css Exemplo 2 | 1,916 Kb |
Animate.css Exemplo 1 | 1,726 Kb |
Three Bullets Spinning | 2,997 Kb |
Flip Cards jAnimate | 4,879 Kb |
A Pen by Renato Ribeiro | 4,442 Kb |
Slide Actions List | 3,296 Kb |
Tinder | 7,391 Kb |
IOS Toggle Checkbox | 2,873 Kb |
PureCSS Tabs | 4,563 Kb |
Orbit | 3,142 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 |
The CodePen Logo | Kindofone | 4,259 Kb |
CSS3 Butterfly | Timohausmann | 3,430 Kb |
Button shaking | SusanneLundblad | 2,227 Kb |
Side Sliding Menu CSS | EduardL | 4,388 Kb |
Christ the Redeemer | Prashantsani | 2,208 Kb |
Resizable SASS Icons | Marianarlt | 7,611 Kb |
Responsive scrolling text | Ashdurham | 2,259 Kb |
Rrremark.com Overlay Highlighter | Derickruiz | 4,438 Kb |
Toolbar | Onsen | 5,414 Kb |
Mostly Fluid | Mccreath | 3,308 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!