Self Correcting Grid. No classes!
How do I make an self correcting grid. no classes!?
I've made a 'grid' that is impermeable to unsightly gaps using pseudo-classes, the general sibling combinator and one Sass for loop.. What is a self correcting grid. no classes!? How do you make a self correcting grid. no classes!? This script and codes were developed by Heydon on 21 August 2022, Sunday.
Self Correcting Grid. No classes! - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Self Correcting Grid. No classes!</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p>Below is a list displayed as a grid. Thanks to pseudo classes, the general sibling combinator and a Sass <code>for</code> loop, you can change the number of columns (the <code>$cols</code> variable) and items (<code><li></code>s) and it will 'self correct' to eliminate gaps. No classes; no worries. For more info on the underlying CSS involved, read <a href="http://www.heydonworks.com/article/tetris-the-power-of-css"><i>Tetris and The Power Of CSS</i></a>.</p>
<ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li>
</ul>
</body>
</html>
Self Correcting Grid. No classes! - Script Codes CSS Codes
/* choose a number of columns */
li { /* set up the basic item widths */ width: 33.33333%;
}
/* this for loop does everything else using nth-child,
nth-last-child and general siblings */
li:nth-child(3n+1):nth-last-child(1) { width: 100%;
}
li:nth-child(3n+1):nth-last-child(1) ~ li { width: 100%;
}
li:nth-child(3n+1):nth-last-child(2) { width: 50%;
}
li:nth-child(3n+1):nth-last-child(2) ~ li { width: 50%;
}
li:nth-child(3n+1):nth-last-child(3) { width: 33.33333%;
}
li:nth-child(3n+1):nth-last-child(3) ~ li { width: 33.33333%;
}
/* below is just boilerplate styles */
* { font-family: sans-serif; margin: 0; padding: 0; border: 2px solid #fff;
}
body { padding: 1em; max-width: 900px; margin: 0 auto;
}
p { margin-bottom: 1em;
}
li { float: left; font-size: 1.5em; font-weight: bold; height: 3em; line-height: 3; margin: -2px; list-style: none; text-align: center; background: #222; color: #fff;
}
code { font-family: monospace;
}
Developer | Heydon |
Username | heydon |
Uploaded | August 21, 2022 |
Rating | 4.5 |
Size | 2,642 Kb |
Views | 26,312 |
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 |
Controlled chaos | 1,562 Kb |
Accessible, pretty radio controls | 2,112 Kb |
Focus management of smooth scrolling | 2,506 Kb |
Hash change logging | 2,134 Kb |
4 columns, no single remainder | 1,563 Kb |
Bookish | 2,094 Kb |
Fukol | 2,461 Kb |
Redesigned gender form field | 1,160 Kb |
Invert custom properties | 2,026 Kb |
Just add javascript | 2,010 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 |
Twitch Live Channels | Inkblotty | 4,956 Kb |
Plotting Points with D3.js | Laurakelly | 31,996 Kb |
How to add Css Fold Notes In Blogger By Askwithloud.com | Askwithloud | 2,280 Kb |
Break Out | AzazelN28 | 12,431 Kb |
TinFoil Boats | Chandralil | 4,577 Kb |
CSS3 Fullscreen Background Slideshow | Leetech | 3,435 Kb |
About Mazano | Kiti | 2,585 Kb |
Fading gradient button | Insprd | 1,713 Kb |
Intake Form Page 2 | Ijantje | 4,983 Kb |
Tab panels | Accessibility | 0 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!