Auto Hexagonal CSS Grid Layout

Developer
Size
3,840 Kb
Views
32,384

How do I make an auto hexagonal css grid layout?

Sizes & lengths with only 1 CSS custom properties (in progress). TODO: shape-outside for texts & vertical centered. What is a auto hexagonal css grid layout? How do you make a auto hexagonal css grid layout? This script and codes were developed by Kseso on 23 August 2022, Tuesday.

Auto Hexagonal CSS Grid Layout Previews

Auto Hexagonal CSS Grid Layout - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Auto Hexagonal CSS Grid Layout</title> <link rel="stylesheet" href="css/style.css">
</head>
<body>	<h1>Auto Hexagonal CSS Grid Layout</h1> <section>	<article>	<figure>	<h2>@Xavisu</h2>	<p>Hola, vengo a flotar. Front~end</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/791963745178181632/rtQQ36JW.jpg' />	</article>	<article>	<figure>	<h2>@rachelandrew</h2>	<p>Web developer, writer, speaker</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/781380559947915265/wrjtv_jp.jpg' />	</article>	<article>	<figure>	<h2>@abelsutilo</h2>	<p>Diseño Productos Digitales. Formador en #UX #U</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/742421353865830400/1D_0DMwU.jpg' />	</article>	<article>	<figure>	<h2>@Olgacarreras</h2>	<p>Consultora freelance. Accesibilidad web y PDF</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/623591872922038272/omSYWMF9.jpg' />	</article>	<article>	<figure>	<h2>@chriscoyier<h2>	<p>braj i was there</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/778921008979935232/5m0hKrUC.jpg' />	</article>	<article>	<figure>	<h2>@lau_es</h2>	<p>#OpenSource rocks! Making awesome things</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/768761020663857152/cFvaG75e.jpg' />	</article>	<article>	<figure>	<h2>@yoksel_en</h2>	<p>CSS and SVG lover : ) In Russian</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/683593501993517056/Bu9pVC8U.jpg' />	</article>	<article>	<figure>	<h2>@jorgeATGU</h2>	<p>front/design Pirineo</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/843198169450254340/qlGpBMyj.jpg' />	</article>	<article>	<figure>	<h2>@SaraSoueidan</h2>	<p>Freelance front-end Web developer & speaker</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/836279399318175745/NrD26zZF.jpg' />	</article>	<article>	<figure>	<h2>@jensimmons</h2>	<p>Designer Advocate at Mozilla. Excited about new CSS for web page layout</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/765902179660161024/zCC2yj_R.jpg' />	</article>	<article>	<figure>	<h2>@AmeliasBrain</h2>	<p>Writer & Developer. SVG guru, policy nut, science nerd, & music fan</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/599278702581534722/WjBaUlMA.jpg' />	</article>	<article>	<figure>	<h2>@desandro</h2>	<p>Designer, developer running @metafizzyco. Gave the internet Masonry</p>	</figure>	<img alt src='https://pbs.twimg.com/profile_images/709468146491645952/MM8N9GdK.jpg' />	</article> </section>	<p>	<code><b>--Nhexa</b></code>: conviene que sea un valor par <code>(2n)</code> por usar el selector <code>:nth-child(2n)</code> para crear el panal y desplazar los hexágonos.</p>	<p><a href='https://escss.blogspot.com/2017/04/auto-hexagonal-css-grid-layout.html'>The post in my blog: now with 2 versions</a></p>
<svg width="0" height="0"> <defs> <clipPath id="hexagono" clipPathUnits="objectBoundingBox"> <polygon points=".25 0, .75 0, 1 .5, .75 1, .25 1, 0 .5" /> </clipPath> </defs>
</svg>
</body>
</html>

Auto Hexagonal CSS Grid Layout - Script Codes CSS Codes

/* working */
*, *:after, *:before { box-sizing: inherit;
}
* {margin:0;padding:0;border: 0 none; position: relative;}
:root {	--sinSerif: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;	--Nhexa: 4;	--gap: 2vw;	--size: calc(calc(100vw / var(--Nhexa)) - var(--gap));
}
@media only screen and (min-width: 1100px) {	:root {	--Nhexa: 6;	}
}
@media only screen and (max-width: 600px) {	:root {	--Nhexa: 2;	}	body {	margin-right: calc(var(--size) * .3);	}
}
html {	background: #e9e9e7; box-sizing: border-box;	font-family: var(--sinSerif);	font-size: 1rem;
}
body {	padding-right: calc(var(--size) * .5);	overflow-X: hidden;
}
section { margin: calc(var(--size) * .5)	auto	0; width: calc(var(--size) * calc(var(--Nhexa) - 1));	display: -ms-grid;	display: grid;	-ms-grid-columns: (1fr)[var]; grid-template-columns: repeat(var(--Nhexa), 1fr);	grid-gap: var(--gap);
}
article {	background: cadetblue; width: var(--size); height: calc(var(--size) / 1.1111111);	-webkit-clip-path: url(#hexagono); clip-path: url(#hexagono); -webkit-clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); margin-right: calc(var(--size) / 2);	color: #fff;	overflow: hidden;
}
article:nth-child(2n) { margin: calc(var(--size) * -.5)	calc(var(--size) * -.25) 0	calc(var(--size) * -.75);
}
article::before {	content: '';	float: left;	width: 25%;	height: 100%;	-webkit-clip-path: polygon(0% 0%, 100% 0%, 0% 50%, 100% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0%, 0% 50%, 100% 100%, 0% 100%);	-webkit-shape-outside: polygon(0% 0%, 100% 0%, 0% 50%, 100% 100%, 0% 100%); shape-outside: polygon(0% 0%, 100% 0%, 0% 50%, 100% 100%, 0% 100%);
}
/*
article::after {	content: '';	float: right;	width: 25%;	height: 100%;	clip-path: polygon(75% 0%, 100% 0%, 100% 100%, 100% 0%);	shape-outside: polygon(75% 0%, 100% 0%, 100% 100%, 100% 0%);
}
*/
img { width: var(--size);	height: var(--size);	position: absolute;	top: 50%;	left: 50%;	-webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);	-webkit-transform-origin: 0% 50%; transform-origin: 0% 50%;	-webkit-transition: .75s;	transition: .75s;	-webkit-clip-path: url(#hexagono); clip-path: url(#hexagono);	-webkit-clip-path: inherit; clip-path: inherit;	z-index: 10;
}
article:hover img {	-webkit-transform: translate(-50%, -50%) rotate(-110deg); transform: translate(-50%, -50%) rotate(-110deg);
}
h1 {	width: 100vw;	background: #FF0066;	position: -webkit-sticky;	position: sticky;	top: 0;	z-index: 1;	margin-bottom: calc(var(--size) * .55 + var(--gap));	padding: 2vh 0;	text-align: center;	font-weight: 400;	color: #fff;
}
figure {	display: -webkit-box;	display: -ms-flexbox;	display: flex;	-webkit-box-orient: vertical;	-webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;	-ms-flex-wrap: nowrap; flex-wrap: nowrap;	-webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;	max-width: 50%;	height: 100%;	font-size: calc(9 / var(--Nhexa) * 1vw);	line-height: 1;	color: #fff;	-webkit-transition: .75s .05s;	transition: .75s .05s;	-webkit-hyphens: auto; -ms-hyphens: auto; hyphens: auto; text-align: center;
}
h2 {font-size: 100%;} figure p {	font-size: 70%;	line-height: 1.2;	font-weight: 100;	width: 100%;
}
body > p {	font-size: 1.5rem;	margin: 2rem 0 1rem calc(var(--size) * .5);	-webkit-hyphens: auto; -ms-hyphens: auto; hyphens: auto;	font-weight: 200;
}
Auto Hexagonal CSS Grid Layout - Script Codes
Auto Hexagonal CSS Grid Layout - Script Codes
Home Page Home
Developer Kseso
Username Kseso
Uploaded August 23, 2022
Rating 4.5
Size 3,840 Kb
Views 32,384
Do you need developer help for Auto Hexagonal CSS Grid Layout?

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!

Kseso (Kseso) 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!