Baseline Grid
How do I make an baseline grid?
Experiments with baseline grid/vertical rhythm.. What is a baseline grid? How do you make a baseline grid? This script and codes were developed by Altitude on 23 September 2022, Friday.
Baseline Grid - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Baseline Grid</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <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! */ /* ========= Get Fonts */
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
/* ================ Assign Variables */
/* =========================== Setup Mixins/Helper Classes */
.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;
}
/* ========== Setup Page */
*, *:before, *:after { box-sizing: border-box;
}
body { background-image: -webkit-linear-gradient(top, transparent 95%, rgba(128, 128, 128, 0.5) 100%); background-size: 100% 20px; padding: 20px; color: #777; font-family: 'Open Sans', sans-serif; font-weight: 600; font-size: 100%; line-height: 2; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto;
}
.baseline-wrap { display: block; margin: 20px 0 20px 0; margin: 1.25rem 0 1.25rem 0; height: auto; overflow: hidden;
}
.baseline-wrap.left { float: left; margin: 0 20px 20px 0; margin: 0 1.25rem 1.25rem 0; max-width: 50%;
}
strong, b { font-weight: 800;
}
ul, ol, p { font-size: 14px; font-size: 0.875rem; line-height: 20px; line-height: 1.25rem; margin: 0 0 20px 0; margin: 0 0 1.25rem 0;
}
blockquote { margin: 0 0 20px 0; margin: 0 0 1.25rem 0; padding: 20px 20px 16px 20px; padding: 1.25rem 1.25rem 1rem 1.25rem; background: rgba(0, 0, 0, 0.0625);
}
blockquote p { margin: 0;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 20px 0; margin: 0 0 1.25rem 0; font-weight: 400; color: #333;
}
h1 strong, h1 b, h2 strong, h2 b, h3 strong, h3 b, h4 strong, h4 b, h5 strong, h5 b, h6 strong, h6 b { font-weight: 800;
}
h1 em, h2 em, h3 em, h4 em, h5 em, h6 em { font-style: normal;
}
h1 { box-sizing: content-box; font-size: 48px; font-size: 3rem; line-height: 60px; line-height: 3.75rem; padding-top: 12px; padding-top: 0.75rem; margin: 0 0 8px -4px; margin: 0 0 0.5rem -0.25rem;
}
h2 { font-size: 40px; font-size: 2.5rem; line-height: 40px; line-height: 2.5rem; padding-top: 5px; padding-top: 0.3125rem; margin: 0 0 15px -3px; margin: 0 0 0.9375rem -0.1875rem;
}
h3 { font-size: 32px; font-size: 2rem; line-height: 40px; line-height: 2.5rem; padding-top: 7px; padding-top: 0.4375rem; margin: 0 0 13px -3px; margin: 0 0 0.8125rem -0.1875rem;
}
h4 { font-size: 24px; font-size: 1.5rem; line-height: 40px; line-height: 2.5rem; padding-top: 11px; padding-top: 0.6875rem; margin: 0 0 9px -2px; margin: 0 0 0.5625rem -0.125rem;
}
h5 { font-size: 18px; font-size: 1.125rem; line-height: 20px; line-height: 1.25rem; padding-top: 3px; padding-top: 0.1875rem; margin: 0 0 17px -1px; margin: 0 0 1.0625rem -0.0625rem;
}
h6 { font-size: 16px; font-size: 1rem; line-height: 20px; line-height: 1.25rem; padding-top: 3px; padding-top: 0.1875rem; margin: 0 0 17px -1px; margin: 0 0 1.0625rem -0.0625rem;
}
p { padding-top: 4px; padding-top: 0.25rem; margin: 0 0 16px 0px; margin: 0 0 1rem 0px;
}
p .baseline-wrap { position: relative; top: -5px; top: -0.3125rem; margin: 20px 0 20px 0px; margin: 1.25rem 0 1.25rem 0px;
}
li { padding-top: 4px; padding-top: 0.25rem; margin: 0 0 -4px 0px; margin: 0 0 -0.25rem 0px;
}
#primary { float: left; width: 60%; padding-right: 3em;
}
#secondary { float: left; width: 40%;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="primary"> <h1> HTML Ipsum Presents </h1> <p> <img class="left" src="http://lorempixel.com/200/200" /><strong>Pellentesque habitant morbi tristique</strong>senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.<em>Aenean ultricies mi vitae est.</em>Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed,ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui.<a href="#"></a>in turpis pulvinar facilisis. Ut felis. </p> <h2> Header Level 2 thats long </h2> <ol> <li> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li> <li> Aliquam tincidunt mauris eu risus. </li> </ol> <h3> Header Level 3 </h3> <ul> <li> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li> <li> Aliquam tincidunt mauris eu risus. </li> </ul> <h4> Header Level 4 </h4> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. </p> <h5> Header Level 5 </h5> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. </p> <h6> Header Level 6 </h6> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. </p>
</div>
<div id="secondary"> <h1> HTML Ipsum Presents </h1> <p> <img src="http://lorempixel.com/1111/544" /><strong>Pellentesque habitant morbi tristique</strong>senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.<em>Aenean ultricies mi vitae est.</em>Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed,ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui.<a href="#"></a>in turpis pulvinar facilisis. Ut felis. </p> <h2> Header Level 2 </h2> <ol> <li> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li> <li> Aliquam tincidunt mauris eu risus. </li> </ol> <blockquote> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida.<img src="http://lorempixel.com/400/350" />Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est. </p> </blockquote> <h3> Header Level 3 </h3> <ul> <li> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li> <li> Aliquam tincidunt mauris eu risus. </li> </ul>
</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>
Baseline Grid - Script Codes CSS Codes
/* ========= Get Fonts */
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
/* ================ Assign Variables */
/* =========================== Setup Mixins/Helper Classes */
.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;
}
/* ========== Setup Page */
*, *:before, *:after { box-sizing: border-box;
}
body { background-image: -webkit-linear-gradient(top, transparent 95%, rgba(128, 128, 128, 0.5) 100%); background-size: 100% 20px; padding: 20px; color: #777; font-family: 'Open Sans', sans-serif; font-weight: 600; font-size: 100%; line-height: 2; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto;
}
.baseline-wrap { display: block; margin: 20px 0 20px 0; margin: 1.25rem 0 1.25rem 0; height: auto; overflow: hidden;
}
.baseline-wrap.left { float: left; margin: 0 20px 20px 0; margin: 0 1.25rem 1.25rem 0; max-width: 50%;
}
strong, b { font-weight: 800;
}
ul, ol, p { font-size: 14px; font-size: 0.875rem; line-height: 20px; line-height: 1.25rem; margin: 0 0 20px 0; margin: 0 0 1.25rem 0;
}
blockquote { margin: 0 0 20px 0; margin: 0 0 1.25rem 0; padding: 20px 20px 16px 20px; padding: 1.25rem 1.25rem 1rem 1.25rem; background: rgba(0, 0, 0, 0.0625);
}
blockquote p { margin: 0;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 20px 0; margin: 0 0 1.25rem 0; font-weight: 400; color: #333;
}
h1 strong, h1 b, h2 strong, h2 b, h3 strong, h3 b, h4 strong, h4 b, h5 strong, h5 b, h6 strong, h6 b { font-weight: 800;
}
h1 em, h2 em, h3 em, h4 em, h5 em, h6 em { font-style: normal;
}
h1 { box-sizing: content-box; font-size: 48px; font-size: 3rem; line-height: 60px; line-height: 3.75rem; padding-top: 12px; padding-top: 0.75rem; margin: 0 0 8px -4px; margin: 0 0 0.5rem -0.25rem;
}
h2 { font-size: 40px; font-size: 2.5rem; line-height: 40px; line-height: 2.5rem; padding-top: 5px; padding-top: 0.3125rem; margin: 0 0 15px -3px; margin: 0 0 0.9375rem -0.1875rem;
}
h3 { font-size: 32px; font-size: 2rem; line-height: 40px; line-height: 2.5rem; padding-top: 7px; padding-top: 0.4375rem; margin: 0 0 13px -3px; margin: 0 0 0.8125rem -0.1875rem;
}
h4 { font-size: 24px; font-size: 1.5rem; line-height: 40px; line-height: 2.5rem; padding-top: 11px; padding-top: 0.6875rem; margin: 0 0 9px -2px; margin: 0 0 0.5625rem -0.125rem;
}
h5 { font-size: 18px; font-size: 1.125rem; line-height: 20px; line-height: 1.25rem; padding-top: 3px; padding-top: 0.1875rem; margin: 0 0 17px -1px; margin: 0 0 1.0625rem -0.0625rem;
}
h6 { font-size: 16px; font-size: 1rem; line-height: 20px; line-height: 1.25rem; padding-top: 3px; padding-top: 0.1875rem; margin: 0 0 17px -1px; margin: 0 0 1.0625rem -0.0625rem;
}
p { padding-top: 4px; padding-top: 0.25rem; margin: 0 0 16px 0px; margin: 0 0 1rem 0px;
}
p .baseline-wrap { position: relative; top: -5px; top: -0.3125rem; margin: 20px 0 20px 0px; margin: 1.25rem 0 1.25rem 0px;
}
li { padding-top: 4px; padding-top: 0.25rem; margin: 0 0 -4px 0px; margin: 0 0 -0.25rem 0px;
}
#primary { float: left; width: 60%; padding-right: 3em;
}
#secondary { float: left; width: 40%;
}
Baseline Grid - Script Codes JS Codes
// A little jQuery to make sure images don't break baseline
var lineHeight = 20;
function update() { $('.baseline-wrap').each(function(){ var $wrap = $(this); var height = Math.floor($wrap.find('img').innerHeight()/lineHeight) * lineHeight; $wrap.css('height',height+'px'); }); console.log('update');
}
$(function(){ $('img').each(function(){ var $img = $(this); var $wrap = $('<div class="baseline-wrap"/>'); var height = Math.floor($img.innerHeight()/lineHeight) * lineHeight; $wrap.addClass($img.attr('class')); $wrap.css('height',height+'px'); $wrap.append($img.clone()); $img.replaceWith($wrap); }); window.setTimeout(update, 1000);
});
$(window).resize(function(){ update()
}); function fixWidows(selector) { $(selector).each(function() { var maxLength = 10; var minLength = 1; var wordArray = $(this).text().split(" "); var secondToLastWord = wordArray[wordArray.length-2]; var lastWord = wordArray[wordArray.length-1]; var doesNotHaveChildren = $(this).children().length == 0; if (doesNotHaveChildren && typeof(secondToLastWord) !== 'undefined' && typeof(lastWord) !== 'undefined' && wordArray.length > 3) { if (lastWord.length >= minLength && lastWord.length <= maxLength) { wordArray[wordArray.length-2] += " " + wordArray[wordArray.length-1]; wordArray.pop(); $(this).html(wordArray.join(" ")); } } }); } fixWidows('h1,h2,h3,h4,h5,h6,p');
Developer | Altitude |
Username | altitudems |
Uploaded | September 23, 2022 |
Rating | 3 |
Size | 7,369 Kb |
Views | 44,528 |
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 |
Semantic Tableless Calendar | 4,528 Kb |
Semantic Tableless Calendar and Agenda | 6,099 Kb |
Jquery Tab Plugin | 5,471 Kb |
VueJS Calendar Component | 8,913 Kb |
Simple CSS Ribbon and Banner | 3,871 Kb |
Custom Social Feeds | 3,750 Kb |
CSS3 Buttons | 5,428 Kb |
Off-Canvas Menu | 4,282 Kb |
VueJS Audio Mixer | 10,100 Kb |
Simple Grid System | 6,136 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 |
Drag and Drop Quiz | Cgspicer | 3,837 Kb |
A Different Type of Gallery | DonPage | 2,950 Kb |
Brown by pure CSS, no image, no javascript | Aaronchuo | 2,652 Kb |
Drag n Drop | Martin42 | 2,594 Kb |
Using Flickr API | MoyArt | 6,761 Kb |
A Pen by John Malc | F789gh | 1,420 Kb |
Animated Vertical CSS3 Menu Black | MaCeLMp4 | 2,750 Kb |
Resume | Rottingroom | 5,483 Kb |
Practice using Wixel | Emnk | 3,057 Kb |
Awesome | Samarthpd | 2,901 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!