Grid Layout changer

Developer
Size
2,314 Kb
Views
8,096

How do I make an grid layout changer?

What is a grid layout changer? How do you make a grid layout changer? This script and codes were developed by Yuri Morini on 24 November 2022, Thursday.

Grid Layout changer Previews

Grid Layout changer - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Grid Layout changer</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="toolbar"> Esempi: <a href="#">1-2-3-3</a> <a href="#">4-2-1-5</a> <a href="#">2-3-4</a>
</div>
<div class="container" data-seq="1-2-3-3"> <div class="element"> <a href="#" class="product">A </a> </div> <div class="element"> <a href="#" class="product">B </a> </div> <div class="element"> <a href="#" class="product">C </a> </div> <div class="element"> <a href="#" class="product">D </a> </div> <div class="element"> <a href="#" class="product">E </a> </div> <div class="element"> <a href="#" class="product">F </a> </div> <div class="element"> <a href="#" class="product">G </a> </div> <div class="element"> <a href="#" class="product">H </a> </div> <div class="element"> <a href="#" class="product">I </a> </div> <div class="element"> <a href="#" class="product">J </a> </div> <div class="element"> <a href="#" class="product">K </a> </div> <div class="element"> <a href="#" class="product">L </a> </div> <div class="element"> <a href="#" class="product">M </a> </div> <div class="element"> <a href="#" class="product">N </a> </div> <div class="element"> <a href="#" class="product">O </a> </div> <div class="element"> <a href="#" class="product">P </a> </div> <div class="element"> <a href="#" class="product">Q </a> </div> <div class="element"> <a href="#" class="product">R </a> </div> <div class="element"> <a href="#" class="product">S </a> </div> <div class="element"> <a href="#" class="product">T </a> </div> <div class="element"> <a href="#" class="product">U </a> </div> <div class="element"> <a href="#" class="product">V </a> </div> <div class="element"> <a href="#" class="product">V </a> </div> <div class="element"> <a href="#" class="product">W </a> </div> <div class="element"> <a href="#" class="product">X </a> </div> <div class="element"> <a href="#" class="product">Y </a> </div> <div class="element"> <a href="#" class="product">Z </a> </div> <div class="element"> <a href="#" class="product"> </a> </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>

Grid Layout changer - Script Codes CSS Codes

body, html { font-family: sans-serif; }
.toolbar { background:#eee; padding: 10px;
}
.toolbar a { display:inline-block; padding: 0 10px;
}
.container { width:100%; background:#ccc; height:100%;
}
.element { width:25%; height:300px; float:left; box-sizing:border-box; padding:10px;
}
.row-1 { width:100%;
}
.row-2 { width:50%;
}
.row-3 { width:33.3%;
}
.product { width:100%; height:100%; display: block; background: #aaa; text-align:center; text-decoration:none; color:#888; vertical-align:middle; line-height: 300px; font-size:30px; font-weight:bold;
}

Grid Layout changer - Script Codes JS Codes

changeLayout( $(".container").attr('data-seq'));
$('.toolbar a').click(function(e) { e.preventDefault(); var a = $(e.target); console.log(a.text()); changeLayout(a.text());
});
function changeLayout(input) { var elements = $(".container .element"); elements.removeClass('row-1 row-2 row-3 row-4 row-5');	var seq = input .split('-') .reduce(function(previousValue, currentValue, index, array) { for (var i = 0; i < currentValue; i++) { previousValue.push('row-' + currentValue); } return previousValue; }, [])	.forEach(function(cls, index, array) { elements.eq(index).addClass(cls);	});
}
Grid Layout changer - Script Codes
Grid Layout changer - Script Codes
Home Page Home
Developer Yuri Morini
Username yurimorini
Uploaded November 24, 2022
Rating 3
Size 2,314 Kb
Views 8,096
Do you need developer help for Grid Layout changer?

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!

Yuri Morini (yurimorini) Script Codes
Create amazing Facebook ads with AI!

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!