Sort Floated UL into columns
How do I make an sort floated ul into columns?
Giving list items float: left and width: 50% is an easy way to columnize the list, but then you end up with the data in rows instead of columns. This bit of javascript rearranges the list items to fix that.. What is a sort floated ul into columns? How do you make a sort floated ul into columns? This script and codes were developed by Matthew Chase on 25 July 2022, Monday.
Sort Floated UL into columns - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Sort Floated UL into columns</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <ul> <li>List Item #1</li> <li>List Item #2</li> <li>List Item #3 with a long title</li> <li>List Item #4</li> <li>List Item #5</li> <li>List Item #6</li> <li>List Item #7</li> <li>List Item #8</li> <li>List Item #9</li> <li>List Item #10</li>
</ul> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Sort Floated UL into columns - Script Codes CSS Codes
UL{ width: 320px; list-style: none; margin: 0; padding: 0;
}
LI{ float: left; width: 50%;
}
LI:nth-child(2n+1){ clear: left;
}
Sort Floated UL into columns - Script Codes JS Codes
$(function(){ $("UL").each(function(){ var list = $(this), items = list.find("LI"), total_items = items.length, half = Math.ceil(total_items / 2); $("LI:lt("+half+")", list).each(function(index, li){ $(li).after(list.find("LI:eq("+(index + half)+")")); }); });
});
Developer | Matthew Chase |
Username | antishow |
Uploaded | July 25, 2022 |
Rating | 3 |
Size | 1,950 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 |
Box Shadow Pixel Art Generator | 14,693 Kb |
Lodash is the shit | 2,841 Kb |
Baby Birds - A Unity for WebGL Game | 2,965 Kb |
Quick Picross | 5,339 Kb |
The Same Three Callouts You Always Do | 2,008 Kb |
THREE.js PointCloud | 3,960 Kb |
Flex-Grow Proportions | 3,276 Kb |
Slow Click Button | 3,035 Kb |
Collision Detection JS Demo | 4,802 Kb |
THREE.js Starter Kit - Basic Stars | 2,212 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 |
Easing | GreenSock | 2,043 Kb |
Disable JavaScript execution from console | Ludviglindblom | 2,534 Kb |
CSS Infinite 360 | APinix | 5,564 Kb |
Wip elementary os navbar | Nickcolley | 2,993 Kb |
Video Player Custom Controls | EleftheriaBatsou | 3,665 Kb |
Tree growth tests | Orchard | 3,818 Kb |
Twinner Spinner II | Katydecorah | 2,974 Kb |
Rainbow Drops | Csbarnes | 2,365 Kb |
Front in Aracaju Logo Pure CSS | Shankarcabus | 2,581 Kb |
Hello People | Danburrows | 2,365 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!