cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              
	<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>@Kseso</h2>
				<p>Enredique Amanuense de CSS</p>
			</figure>
			<img alt src='https://pbs.twimg.com/profile_images/722022140455821313/hrRtW6LJ_400x400.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/883049860332609537/IsUISvAq_400x400.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/892999311256035329/ua06He_U_400x400.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/903537944320987136/wB28L8qd_400x400.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><b>Please</b>, show the pen & link the post: <a href='https://escss.blogspot.com/2017/04/auto-hexagonal-css-grid-layout.html'>The post in my blog: now with 2 versions</a>. Thanks</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>
            
          
!
            
              *, *: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;
	hyphens: auto;
}
section {
  margin: calc(var(--size) * .5) auto 0;
  width: calc(var(--size) * calc(var(--Nhexa) - 1));
	display: grid;
	grid-template-columns: repeat(var(--Nhexa), 1fr);
	grid-gap: var(--gap);
}
article {
	background: cadetblue;
  width: var(--size); 
  height: calc(var(--size) / 1.1111111);
	clip-path: url(#hexagono);
  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%;
	clip-path: polygon(0% 0%, 100% 0%, 0% 50%, 100% 100%, 0% 100%);
	shape-outside: polygon(0% 0%, 100% 0%, 0% 50%, 100% 100%, 0% 100%);
}
img {
  width: var(--size);
	height: var(--size);
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transform-origin: 0% 50%;
	transition: .75s;
	clip-path: url(#hexagono);
	clip-path: inherit;
	z-index:  10;
}
article:hover img {transform: translate(-50%, -50%) rotate(-110deg);}
h2 {font-size: 100%;}
figure {
	display: flex;
	flex-direction: column;
	flex-wrap: nowrap;
	justify-content: center;
	max-width: 50%;
	height: 100%;
	font-size: calc(9 / var(--Nhexa) * 1vw);
	line-height: 1;
	color: #fff;
	transition: .75s .05s;
  text-align: center;
}
figure p {
	font-size: 70%;
	line-height: 1.2;
	width: 100%;
}
h1 {
	width: 100vw;
	background: #FF0066;
	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;
}
body > p {
	font-size: 1.5rem;
	margin: 2rem 0 1rem calc(var(--size) * .5);
	font-weight: 200;
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console